早教吧作业答案频道 -->其他-->
求高人指教java复习题java编程复习题1图形系列编写程序输出如下图形.(a)##########(b)%%%%%%%%%%%%%%%%(c)&&&&&&$$$$$$&&&&&&$$$$$$(d)********2数组系列(a)定义数组A,该数组由用户任意输入的50个整形数据
题目详情
求高人指教java复习题
java编程复习题
1 图形系列
编写程序输出如下图形.
(a)
#
##
###
####
(b)
%
%%%
%%%%%
%%%%%%%
(c)
&&&&&&
$$$$$$
&&&&&&
$$$$$$
(d)
*
***
***
*
2数组系列
(a) 定义数组A,该数组由用户任意输入的50个整形数据组成,显示输出最大数并输出该数对应的下标.
(b) 定义数组B,由50个整型数组元素组成,将它们按从小到大的方式输出.(冒泡法,选择法排序).
(c) 定义数组C,由30个整型数组元素组成,实现数组元素的转置,分别输出转置前的数组和转置后的数组.
例如:C数组为:
c[0] c[1] .c[28] c[29]
1 9 .100 12
则转置后为:
c[0] c[1] .c[28] c[29]
12 100 .9 1
java编程复习题
1 图形系列
编写程序输出如下图形.
(a)
#
##
###
####
(b)
%
%%%
%%%%%
%%%%%%%
(c)
&&&&&&
$$$$$$
&&&&&&
$$$$$$
(d)
*
***
***
*
2数组系列
(a) 定义数组A,该数组由用户任意输入的50个整形数据组成,显示输出最大数并输出该数对应的下标.
(b) 定义数组B,由50个整型数组元素组成,将它们按从小到大的方式输出.(冒泡法,选择法排序).
(c) 定义数组C,由30个整型数组元素组成,实现数组元素的转置,分别输出转置前的数组和转置后的数组.
例如:C数组为:
c[0] c[1] .c[28] c[29]
1 9 .100 12
则转置后为:
c[0] c[1] .c[28] c[29]
12 100 .9 1
▼优质解答
答案和解析
楼主提了两个这样的问题?刚才回复了那个,在这里再把结果贴出来吧.楼主觉得满意,请把两个问题都结了,谢谢.
新建类:BaiduZhidao编译直接运行
package test;
public class BaiduZhidao {
public static void main(String[] args) {
System.out.println("1 图形系列\n编写程序输出如下图形.\n(a)");
a();
System.out.println("\n(b)");
b();
System.out.println("\n(c)");
c();
System.out.println("\n(d)");
d();
System.out.println("\n(e)");
e();
System.out.println("\n2 数组系列\n(a)定义数组A,该数组由用户任意输入的50个整形数据组成,显示输出最大数并输出该数对应的下标.");
a2();
System.out.println("\n(b)定义数组B,由50个整型数组元素组成,将它们按从小到大的方式输出.(冒泡法,选择法排序).");
b2();
System.out.println("\n\n(c)定义数组C,由30个整型数组元素组成,实现数组元素的转置,分别输出转置前的数组和转置后的数组.");
c2();
}
public static void a()
{
int row = 4;//图形行数,修改此数字来改变图形大小.
for(int i = 1 ; i max)
{
max = a[i];
index = i;
}
}
//打印结果.
System.out.println("数组:");
for(int i = 0 ; i < a.length ; i ++)
{
System.out.print( a[i]+" ");
}
System.out.println("\n最大:"+max + " 下标:"+index);
}
public static void b2()
{
//定义数组B并生成0-500的随机数放入数组.
int length = 50;//数组长度,可随意修改
int[] b = new int[length];
for(int i = 0 ; i < length ; i ++)
{
b[i] = (int)(Math.random()*500);
}
//排序,冒泡
int temp = 0 ;
for(int i = 0 ; i < b.length ; i ++)
{
for(int j = 0 ; j < b.length-1 ; j ++)
{
if(b[j] > b[j+1])
{
temp = b[j+1];
b[j+1] = b[j];
b[j] = temp;
}
}
}
//打印结果.
System.out.println("数组:");
for(int i = 0 ; i < b.length ; i ++)
{
System.out.print( b[i]+" ");
}
}
public static void c2()
{
//定义数组c并生成0-500的随机数放入数组.
int length = 30;//数组长度,可随意修改
int[] c = new int[length];
for(int i = 0 ; i < length ; i ++)
{
c[i] = (int)(Math.random()*500);
}
System.out.println("原始数组:");
for(int i = 0 ; i < c.length ; i ++)
{
System.out.print( c[i]+" ");
}
//转置
int temp = 0 ;
for(int i = 0 ; i < length/2 ; i ++)
{
temp = c[i];
c[i] = c[length - i -1];
c[length - i -1] = temp;
}
System.out.println("\n转换后数组:");
for(int i = 0 ; i < c.length ; i ++)
{
System.out.print( c[i]+" ");
}
}
}
新建类:BaiduZhidao编译直接运行
package test;
public class BaiduZhidao {
public static void main(String[] args) {
System.out.println("1 图形系列\n编写程序输出如下图形.\n(a)");
a();
System.out.println("\n(b)");
b();
System.out.println("\n(c)");
c();
System.out.println("\n(d)");
d();
System.out.println("\n(e)");
e();
System.out.println("\n2 数组系列\n(a)定义数组A,该数组由用户任意输入的50个整形数据组成,显示输出最大数并输出该数对应的下标.");
a2();
System.out.println("\n(b)定义数组B,由50个整型数组元素组成,将它们按从小到大的方式输出.(冒泡法,选择法排序).");
b2();
System.out.println("\n\n(c)定义数组C,由30个整型数组元素组成,实现数组元素的转置,分别输出转置前的数组和转置后的数组.");
c2();
}
public static void a()
{
int row = 4;//图形行数,修改此数字来改变图形大小.
for(int i = 1 ; i max)
{
max = a[i];
index = i;
}
}
//打印结果.
System.out.println("数组:");
for(int i = 0 ; i < a.length ; i ++)
{
System.out.print( a[i]+" ");
}
System.out.println("\n最大:"+max + " 下标:"+index);
}
public static void b2()
{
//定义数组B并生成0-500的随机数放入数组.
int length = 50;//数组长度,可随意修改
int[] b = new int[length];
for(int i = 0 ; i < length ; i ++)
{
b[i] = (int)(Math.random()*500);
}
//排序,冒泡
int temp = 0 ;
for(int i = 0 ; i < b.length ; i ++)
{
for(int j = 0 ; j < b.length-1 ; j ++)
{
if(b[j] > b[j+1])
{
temp = b[j+1];
b[j+1] = b[j];
b[j] = temp;
}
}
}
//打印结果.
System.out.println("数组:");
for(int i = 0 ; i < b.length ; i ++)
{
System.out.print( b[i]+" ");
}
}
public static void c2()
{
//定义数组c并生成0-500的随机数放入数组.
int length = 30;//数组长度,可随意修改
int[] c = new int[length];
for(int i = 0 ; i < length ; i ++)
{
c[i] = (int)(Math.random()*500);
}
System.out.println("原始数组:");
for(int i = 0 ; i < c.length ; i ++)
{
System.out.print( c[i]+" ");
}
//转置
int temp = 0 ;
for(int i = 0 ; i < length/2 ; i ++)
{
temp = c[i];
c[i] = c[length - i -1];
c[length - i -1] = temp;
}
System.out.println("\n转换后数组:");
for(int i = 0 ; i < c.length ; i ++)
{
System.out.print( c[i]+" ");
}
}
}
看了 求高人指教java复习题ja...的网友还看了以下:
大家看看这个lingo程序哪里错了啊····谢谢各位model:title first steps 2020-05-13 …
用matlab求最短距离时出现问题,function [D,path,min1,path1]=fl 2020-05-17 …
model:sets:yh/1,2,3/:;fq/1,2,3/:;link(yh,fq):x,d; 2020-06-12 …
选出下列词语中注音有误的一项:A.豆豉zhǐ殴ōu打金瓯ōu呕ǒu吐B.迂讷nè炖dùn菜利钝dù 2020-06-28 …
下列程序运行后的输出结果是()#includemain(){inti=1,j=3printf("% 2020-07-23 …
三元一次方程组a*x+b*y+c*z+d=0,e*x+f*y+g*z+h=0,i*x+j*y+k* 2020-08-03 …
求助C语音的作业,我不是学这个的已知:inti=13,j=17,a=4,x=1,y=2,z=3,d; 2020-10-30 …
选出下列各句中注音错误的一项:()A.青蒿hāo犟jiàng嘴踉liàng跄qiàngB数落luo贫 2020-11-06 …
求解析:已知inti,j,k;scanf(“%d%d%d”,&i,&j,&k);若从键盘送入i,j, 2021-01-05 …
用石灰石(杂质不与酸反应,也不溶于水)和稀盐酸反应,制取二氧化碳,现将20g石灰石盛入烧杯j后,再加 2021-02-06 …