天空是藍色的

          做好軟件為中國 #gcc -c helloworld.c -o helloworld.o //編譯目標文件 #gcc helloworld.o -o helloworld //編譯成可執行exe #helloworld //運行exe

          公告


           

          常用鏈接

          留言簿(9)

          隨筆分類(149)

          隨筆檔案(151)

          文章分類(31)

          文章檔案(31)

          C編譯器

          leemay`s

          朋友的blog

          相冊

          計算機原理

          鏈接

          搜索

          •  

          積分與排名

          • 積分 - 450179
          • 排名 - 121

          最新隨筆

          最新評論

          閱讀排行榜

          評論排行榜

          水仙花問題
          解法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 閱讀(577) 評論(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;
          }
            回復  更多評論    
          主站蜘蛛池模板: 育儿| 莱阳市| 沧源| 威宁| 普格县| 鄄城县| 义马市| 喀喇沁旗| 宜兴市| 绥江县| 夏河县| 高青县| 汝南县| 梅州市| 贡觉县| 绥德县| 成都市| 宁明县| 茶陵县| 大洼县| 沁水县| 盐山县| 涞水县| 慈利县| 涟水县| 社会| 建瓯市| 罗城| 颍上县| 志丹县| 鸡西市| 卓尼县| 翼城县| 泸定县| 鹤岗市| 临泉县| 昌乐县| 绍兴县| 嘉祥县| 保靖县| 玉山县|