
循环
文章平均质量分 62
dqw~
这个作者很懒,什么都没留下…
展开
-
java两矩阵相加(二维矩阵重要细节解析)
type 数组名[][] type[][] 数组名 如 int array[][]=new int[3][]; 生成3个一维数组array array[0]=new int[2]; 生成第0维的1维数组array[0],含2个int值,初始化为0; array[1]=new int[4]; array[2]=new int[2]; 生成array第一维的一维数组和第二维的一维数组,初始化为0...原创 2020-05-02 12:20:31 · 1304 阅读 · 0 评论 -
一维数组求100个素数(最高效率方法)
public class welcome{ public static void main(String[] args){ int n[]=new int[100]; int p=1,cn=1; n[0]=2; System.out.printf("\t"+n[0]); for(int k=1;k<100;) { p+=2; int j=0; bool...原创 2020-05-01 15:22:50 · 932 阅读 · 0 评论 -
输入一正整数,将各数字反转后输出
正整数先输出个位,后输出十位,以此类推 使用do-while循环 import java.io.*; public class welcome{ public static void main(String[] args) throws IOException{ int x; InputStreamReader ir=new InputStreamReader(System.in); ...原创 2020-04-30 17:47:20 · 1528 阅读 · 0 评论 -
计算平均成绩,科目数未知
当学生的科目总数未知,循环输入的数据次数未知,需要循环的结束条件,并且需要一个count计数器 import java.io.*; public class welcome{ public static void main(String[] args) throws IOException{ int score; int count=0; float sum=0; float a...原创 2020-04-30 17:29:07 · 204 阅读 · 0 评论 -
求自然数求和
求自然数1~n的和 import java.io.*; public class welcome{ public static void main(String[] args) throws IOException{ int sum=0; int n; InputStreamReader ir; BufferedReader in; ir=new InputStreamRea...原创 2020-04-30 16:03:59 · 626 阅读 · 0 评论