/// <summary>///100 The number of 7 or less/// </summary> Public voidSeven () {Console.WriteLine ("within 100, the number of 7-related numbers is:"); intCount =0; for(intnum =1; Num <= -; num++ ) { if((num%Ten==7) || (num/Ten==7) || (num/ -==7) || (num%7==0) ) {count++; Console.Write (Num+"\ t"); }} Console.WriteLine ("Total"+ Count +"a"); }Static voidMain (string[] args) {Program Hanshu=NewProgram (); Hanshu. Seven (); Console.ReadLine ();
<summary>
99 table, one line to print
</summary>
Public voidjiujiutable () { for(intHang =1; Hang <=9; hang++) { for(intLie =1; Lie <= hang; lie++) {Console.Write (Lie+"*"+ Hang +"="+ Hang * lie+"\ t"); } Console.WriteLine (); } console.readline (); }Static voidMain (string[] args) {Program Hanshu=NewProgram (); Hanshu. Jiujiutable (); Console.ReadLine (); }
/// <summary>///within 100 odd and/// </summary> Public voidJishuhe () {intsum =0; for(intnum =1; Num <= -; num + =2) {sum= Sum +num; Console.WriteLine (Num+"within the odd and:"+sum); } }Static voidMain (string[] args) {Program Hanshu=NewProgram (); Hanshu.jishuhe (); Console.ReadLine (); }
/// <summary>///1 cents, 2 cents, 5 cents of coins, combined out 6 cents, three kinds of coins have, there are several ways/// </summary> Public voidYingbi () {intCount =0; for(intx=1; x< -; X + +) { for(inty=1; y< -; y++) { for(intz=1; z< A; z++) { if(x + y *2+ Z *5== -) {Count++; Console.WriteLine ("1 cents"+ x +"one, 2 cents."+ y +"one, 5 cents."+ z +"a"); } }}} Console.WriteLine ("Total"+count+"kind of Method"); }Static voidMain (string[] args) {Program Hanshu=NewProgram (); Hanshu.yingbi (); Console.ReadLine (); }
Exercise: C #---Functions (100 of 7 related numbers, 99 multiplication tables, 100 odd and coin combinations)