早教吧作业答案频道 -->其他-->
求高人指教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...的网友还看了以下:
在matlab中,如何定义函数式子中的未知常数.即,在做某个迭代程序时,函数中含有未知常数(用字母 2020-05-14 …
.加点字的读音全部正确的一组是()A.骈(pián)体矩(jǔ)形分(fèn)外校(jiào)对B 2020-05-15 …
Fori=1To10f=TrueForj=1To9Ifa(j)>a(j+1)Thent=a(j)a 2020-05-23 …
forj=1to9ifa(j)>a(j+1)thent=a(j)a(j)=a(j+1)a(j+1) 2020-05-23 …
运行如下lingo程序时,出现indexvariablesmaynotsharenameswith 2020-06-12 …
matlab微分方程组求解symsa,b,c,d;dsolve('Dy(1)=1/2*a*y(2) 2020-07-21 …
三元一次方程组a*x+b*y+c*z+d=0,e*x+f*y+g*z+h=0,i*x+j*y+k* 2020-08-03 …
求教.求矢量场A=x²i+y²j+(x+y)zk通过点M(2,1,1)的矢量线方程A,i,j,k都 2020-08-03 …
如图为美国生态学家林德曼对赛达伯格湖的能量流动图解,图中的数字为能量数值,单位是J/(cm2•a). 2021-01-15 …
在VB中下面段程序是什么意思怎样运行的?J=1FORI=100TO4000STEP5DIST(J)= 2021-02-05 …