天空是藍色的

          做好軟件為中國 #gcc -c helloworld.c -o helloworld.o //編譯目標文件 #gcc helloworld.o -o helloworld //編譯成可執行exe #helloworld //運行exe
          數據加載中……
          水仙花問題
          解法1
          #include <stdio.h> 
          int main() 

          int shu
          ,bai,shi,ge; 
           for (shu=100;shu<1000;shu++) 
           { 
           bai
          =shu/100; 
           shi=(shu-bai*100)/10; 
           ge=shu-bai*100-shi*10; 
           if(shu==(bai*bai*bai+shi*shi*shi+ge*ge*ge)) 
           printf(
          "%d\n",shu); 
           } 

          解法2
          int main(){ 
          int a
          ,b,c,num; 
          for(a=1;a<10;a++){ 
          for(b=0;b<10;b++){ 
          for(c=0;c<10;c++){ 
          if(a*100+b*10+c==(num=a*a*a+b*b*b+c*c*c)) 
          printf(
          "%d",num); 




          posted on 2006-02-13 17:24 bluesky 閱讀(571) 評論(1)  編輯  收藏 所屬分類: C/C++

          評論

          # re: 水仙花問題 2008-07-10 12:24 

          #include <stdio.h>
          int main(void)
          {
          int a,b,c,d,e,f,g,h;
          a=100;
          for(g=0;g<899;g++)
          {
          a=a+1;
          c=a/100;
          d=(a-c*100)/10;
          e=a-(c*100+d*10);
          h=c*c*c+d*d*d+e*e*e;
          if(h==a)
          printf("%d,",a);
          }
          scanf("%d",f);
          return f;
          }
            回復  更多評論    
          主站蜘蛛池模板: 邵东县| 积石山| 得荣县| 宁城县| 台中县| 长寿区| 凤阳县| 巴南区| 台东县| 安溪县| 新兴县| 广宁县| 女性| 梨树县| 明光市| 镇江市| 开封市| 贵溪市| 临汾市| 乌什县| 西安市| 邹平县| 辉南县| 若羌县| 祁东县| 呼和浩特市| 贡嘎县| 庆云县| 兴安盟| 云安县| 四子王旗| 西充县| 静海县| 沾化县| 永顺县| 白银市| 尚义县| 三门县| 永定县| 临海市| 台州市|