摘要:
思路一:根据n的次数重复计算数的和,下一次要加的数等于上一个数扩大10倍再加上上一次的i,需要变量记录上一个计算的数,需要变量记录原始i 2+(2*10+2)+(22*10+2)+(222*10+2) public static void main(String[] args){ Scanner s 阅读全文
posted @ 2020-04-06 23:23
小小野生程序员sunny
阅读(522)
评论(0)
推荐(0)
摘要:
public static void main(String[] args){ int a=1; int b=2; int temp; //循环10次 for(int i=0;i<=10;i++){ //保存原来分子 temp=a; //将原分母赋给现在的分子 a=b; //将原来的分母+分子赋给现 阅读全文
posted @ 2020-04-06 23:04
小小野生程序员sunny
阅读(191)
评论(0)
推荐(0)
摘要:
public static void main(String[] args){ Scanner sc=new Scanner(System.in); Random ran=new Random(); //随机生成1-100的数字 int n=ran.nextInt(100)+1; int i=1; 阅读全文
posted @ 2020-04-06 22:59
小小野生程序员sunny
阅读(936)
评论(0)
推荐(0)
摘要:
public static void main(String[] args){ Scanner sc=new Scanner(System.in) //记录登录错误的次数 int i=0; while(true){ //登录一次记录一次 i++; //如果大于5则提示冻结 if(i>5){ sout 阅读全文
posted @ 2020-04-06 13:28
小小野生程序员sunny
阅读(789)
评论(0)
推荐(0)
摘要:
public static void main(String[] args){ //记录报数的还剩多少人 int n=30; //记录总的报数次数 int count=0; //记录每个人报的数 int i=0; //当人数还剩一个的时候跳出循环 while(n!=1){ //累计报数的总次数 co 阅读全文
posted @ 2020-04-06 13:27
小小野生程序员sunny
阅读(589)
评论(0)
推荐(0)
摘要:
控制流有两种结构: 条件结构 循环结构 条件结构三种:基本条件结构,多重条件结构,switch条件结构 循环结构三种:while循环 do-while循环 for循环 while循环:先判断条件,再执行循环操作,通常在未知循环次数时使用(只知道满足什么条件时停止,不清楚要循环多少次) do-whil 阅读全文
posted @ 2020-04-06 00:08
小小野生程序员sunny
阅读(788)
评论(0)
推荐(0)

浙公网安备 33010602011771号