竖式问题

 1 #include<stdio.h>
 2 #include<string.h>
 3 int main()
 4 {
 5     int count = 0;
 6     int abc,de,i;
 7     char s[20],buf[99];
 8     scanf("%s",s);
 9     for(abc=111;abc<=999;abc++)
10     {
11         for(de=11;de<=99;de++)
12         {
13             int x=abc*(de%10),y=abc*(de/10),z=abc*de;
14             sprintf(buf,"%d%d%d%d%d",abc,de,x,y,z);
15             int ok=1;
16             for(i=0;i<strlen(buf);i++)
17                 if(strchr(s,buf[i])==NULL)
18                 ok=0;
19             if(ok)
20             {
21                 printf("<%d>\n",++count);
22                 printf("%5d\nX%4d\n-----\n%5d\n%4d\n------\n%5d\n\n",abc,de,x,y,z);
23             }
24         }
25     }
26    printf("The number of solutions = %d\n",count);
27     return 0;
28 }

 

刚刚开始研究这本书,这个程序,最让我感到疑惑的是那两个循环,为什么从111开始,而不是100开始呢?

posted @ 2017-08-12 17:50  努力更加美好  阅读(419)  评论(0编辑  收藏  举报