早教吧作业答案频道 -->其他-->
求高人指教java复习题java编程复习题(将正确的代码写到笔记本上):1图形系列编写程序输出如下图形.(a)##########(b)%%%%%%%%%%%%%%%%(c)&&&&&&$$$$$$&&&&&&$$$$$$(d)********2数组系列(a)定义数组A,该数组
题目详情
求高人指教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编译直接运行查看结果.
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]+" ");
}
}
}
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...的网友还看了以下:
有a,b,c三组.a组有7人,b、c组都有14人.在总共35人中随机抽两人.问两人分别为1个b组1 2020-05-16 …
四年级甲班去划船,全班分成A,B,c三组,共租了11只船,租费由三个小租平摊,A组付了7只船的租金 2020-06-16 …
取30只大小相同的幼鼠分为A,B,C三组,分别放入3个饲养笼.给A组幼鼠定期注射适量生长激素,B组 2020-06-30 …
找规律,回答问题!要快啊.在线等把自然数1~200按下面的方法分成A,B,C三组.A组167121 2020-07-18 …
坐标平面内有4个点A(0,2),B(-1,0),C(1,-1),D(3,1).(1)建立坐标系,描 2020-08-02 …
某校组织可为活动小组一共50人份A,B,C三组,B组人数是A,C两组人数之和的1/4,A组人数恰好 2020-08-03 …
关于重复选出同—组数据的概率假设有A,B,C三组,A组被选出的概率是55%,B组被选出的概率是21% 2020-10-30 …
新概念作文大赛的奖项是按照a.b.c三组分别评奖吗听说大赛按年龄分为a.b.c三组分开了参加的人,那 2020-11-10 …
绕弯的题,我被绕晕了,求函数有七组数据,ABCDEFG,已知A,B,C,七组数据的关系D+E=B,F 2020-11-11 …
把自然数1到200按下面的方法分成a,b,c三组,152是那组的第几个数?c组第23个数是多少?a: 2020-12-26 …