Yang Hui?:
1#include <stdio.h>2 intMain ()3{inti,j,n=0, a[ -]={0,1},l,r;4 while(n<1|| N> -)5{printf ("Please enter the number of lines for the Yang Hui triangle:");6scanf"%d",&n);7 }8 for(i=1; i<=n;i++)9{l=0;Ten for(j=1; j<=i;j++) One{r=A[j]; Aa[j]=l+R; -L=R; -printf"%5d", A[j]); the } -printf"\ n"); - } - return 0; + -}
99 Multiplication Table:
1#include <stdio.h>2 3 intMain ()4 {5 intI,j =0;6 for(i =1; I <=9; i++)7 {8 for(j =1; J <=9; j + +)9 {Ten if(I >=j) One { Aprintf"%d*%d=%d\t", i,j,i*j); - } - } thePutchar ('\ n'); - } - return 0; -}
Number of daffodils:
1#include <stdio.h>2 3 intMain ()4 {5 intI, j, K,num =0;6 for(i=1; I <Ten; i++){7 for(j=0; J <Ten; j + +){8 for(k=0; k <Ten; k++)9 {Ten if(I*i*i+j*j*j+k*k*k = = i* -+j*Ten+k) One { A -printf"%d\t", -*i+Ten*j+k); - } the } - - - } + - + } A atprintf"\ n"); - - return 0; -}
To determine the reverse print of a positive integer less than or equal to five bits:
1#include <stdio.h>2 3 intMain ()4 {5 intNum,n =0;6 intA,b,c,d,e =0;7 8 while(1){9printf"* * Please enter a number for the number of digits, let me guess **\n");Tenscanf"%d",&num); One A - if(Num >=Ten&& Num <=99999 ) - { theA = num/10000;//million-bit -b = num/ +%Ten;//thousand -c = num/ -%Ten;//Hundred -d = num/Ten%Ten;//10 Guests +e = num%Ten;//Digit - + A if(num/10000>=1) at { -n =5; -printf"* * * * *, so simple! Turns out this is a%d-digit *****\n", n); -printf"%d%d%d%d%d \ n", a,b,c,d,e); -printf"%d%d%d%d%d \ n", e,d,c,b,a); - } in Else if(num/ +>=1&& num/10000<1 ) - { ton =4 ; +printf"* * * * you're teasing me, this is obviously a%d-digit number ****\n", n); -printf"%d%d%d%d \ n", b,c,d,e); theprintf"%d%d%d%d \ n", e,d,c,b); * $ }Panax Notoginseng Else if(num/ ->=1&& num/ +<1 ) - { then =3; + Aprintf"* * hahaha, this is a%d-digit ***\n", n); theprintf"%d%d%d\n", c,d,e); +printf"%d%d%d \ n", e,d,c); - $ } $ Else if(Num/Ten>=0&& num/ -<1) - { -n =2; theprintf"* * Yes, this is a%d-digit **\n", n); -printf"%d%d \ n", d,e);Wuyiprintf"%d%d \ n", e,d); the - } Wu } - Else if(Num >0&& Num <=9) About { $n =1; -printf"* This is a%d-digit number WOW *\n", n); - -printf"%d\n", num); Aprintf"%d\n", num); + the } - $ the } the the the - in return 0; the}
Some exercises in C language