摘要:
for的穷举 把所有可能的情况都走一遍,使用if条件筛选出来满足条件的情况。 例: 单位给发了一张150元购物卡,拿着到超市买三类洗化用品。洗发水15元,香皂2元,牙刷5元。求刚好花完150元,有多少种买法,每种买法都是各买几样? 设洗发水 x 150/15==10牙刷 y 150/5==30香皂 阅读全文
摘要:
循环语句forfor (; ; )//你不跳出,它就是死循环!!! 打印20遍你好。 for (int i = 1; i <= 20; i++) { if (i == 6) { continue;// } Console.WriteLine("你好!"); } i 为循环次数。 例: 输入一个整数, 阅读全文
摘要:
Console.WriteLine("1.汉堡包"); Console.WriteLine("2.薯条"); Console.WriteLine("3.鸡块"); Console.WriteLine("4.鸡腿"); Console.WriteLine("5.鸡米花"); Console.Write 阅读全文
摘要:
int a = 10; if (a < 10) { a++; } if (a > 3) ; { a--; } Console.WriteLine(a); Console.ReadLine(); if(){} else{}若if成立,则不去走else若if不成立,则一定会走else int a = 1 阅读全文
摘要:
算术运算符 ++ -- 放置在变量名前面或者后面 int a = 1; int b = a++;//int b=a ;a=a+1; int c = ++a;//a=a+1;int c=a; Console.WriteLine(a); Console.WriteLine(b); Console.Wri 阅读全文