1. Tournament ranking times. /* #include <stdio.h>int main () {int i=0,j=0,k=0,count=0;for (i=1;i<=4;i++) { for (j=1;j<=4;j++) {for (k=1;k<=4;k++) {if (i!=j&&j!=k&&i!=k) {printf ( "%d%d%d ", i,j,k); count++;}}} printf ("count=%d", Count);p rintf ("\ n"); return 0;} */2. Murderer #include<stdio.h>int main () {int a,b,c,d,e;for ( a=1;a<=5;a++) for ( b=1;b< =5;b++) for (c=1;c<=5;c++) for (d=1;d<=5;d++) for (e=1;e<=5;e++) if (((b==1) ^ (a==3)) && ((b==2) ^ (e==4)) && ((c==1) ^ (d==2)) && ((c==5) ^ (d==3)) && ((e==4) ^ (a==1)) {printf ("%d %d %d % d %d ", a,b,c,d,e); return 0;}} 3. Yang Hui triangle/* #include <stdio.h>int main () { int i,j,n=0,a[40][40]= {0}; printf ("Enter Number of lines:"), scanf ("%d", &n); for (i=0;i<n;i++) a[i][0] =1; for (i=1;i<n;i++) for (j=1;j<=i;j++) a[i][j]=a[i-1][j-1]+a[i-1][j]; for (i=0;i<n;i++) { for (j=0;j<=i;j++) { printf ("%5d", a I [j]);} printf ("\ n"); }return 0;} */4. Recursive positive sequence outputs each bit of an integer. /* #include <stdio.h>int main () {int c (int x); INT&NBSP;I;INT&NBSP;J;SCANF ("%d", &i); j= c(i);p rintf ("\ n"); return 0;} Int c (int x) {int b;b=x%10;x=x/10;if (x!=0) { c (x);} printf ("%d", b);} */5. Star symmetry/* #include <stdio.h>int main () {int i,j,line;printf ("Please enter the number of pattern lines:"), scanf ("%d", &line); For (i=0;i< (line+1)/2;i++) {for (j=0;j< (line+1)/2-1-i;j++) printf (" "), for (j=0;j<2*i+1;j++) printf ("*");p rintf ("\ n");} For (i= (line+1)/2;i<line;i++) {for (j=0;j< (line+1)/2-line+i;j++) printf (" "), for (j=0;j<2* (line-1-i) + 1;j++) printf ("*");p rintf ("\ n");} return 0;} */
******************
To determine how braces match in a program:
/* #include <stdio.h>
int main ()
{
int i=0;
int ch;
while (eof!= (Ch=getchar ()))
{
if (ch== ' {')
i++;
if (ch== '} ' &&i==0)
{
printf ("Unmatch");
return 0;
}
else if (ch== '} ')
i--;
}
if (i==0)
printf ("Match");
Else
printf ("Unmatch");
return 0;
}*/
Read the number of TRIPS and print the content
/* #include <stdio.h>
int main ()
{
int ch=0;
int flag=1;
int line=1;
while (eof!= (Ch=getchar ()))
{
if (flag)
{
printf ("%d", line);
flag=0;
}
Putchar (CH);
if (ch== ' \ n ')
{
flag=1;
line++;
}
}
Return 0;*/
This article is from the "Small Stop" blog, please be sure to keep this source http://10541556.blog.51cto.com/10531556/1676455
C Language Applet (small program Knowledge)