1. 程式人生 > >用c語言實現輸入和為n的迴文數

用c語言實現輸入和為n的迴文數

#include<stdio.h>
 int main()
 { 
     int a,b,c,d,e,f,n;
     scanf("%d",&n);
     if(1<=n<=54) 
     {
         for(a=0;a<=9;a++) 
         { 
             for(b=0;b<=9;b++)
             {
                 for(c=0;c<=9;c++)
             { 
                     for(d=0;d<=9;d++) 
             {
                         for
(e=0;e<=9;e++) { for(f=0;f<=9;f++) { if(a+b+c+d+e+f==n) { if(a==f&&b==e&&c==d) printf("%d%d%d%d%d%d\n",a,b,c,d,e,f); } } } } } } } } }

這裡寫圖片描述