码迷,mamicode.com
首页 > 其他好文 > 详细

实验3

时间:2019-05-09 15:40:18      阅读:109      评论:0      收藏:0      [点我收藏+]

标签:for   水仙花   技术   .com   mamicode   img   color   mic   stdio.h   

技术图片技术图片
#include <stdio.h>
int main()
{

long t,s;
t=22;
s=0;
for (t=22;t<=1002;t+=20)
    s+=t;
printf("%d",s);
return 0;
}

 

#include <stdio.h>
int main()
{

long t,s;
t=22;
s=0;
while (t<=1002)
{s+=t;
t+=20;}
printf("%d",s);
return 0;
}

技术图片

#include <stdio.h>
int main()
{

long t,s;
t=22;
s=0;
do
{s+=t;
t+=20;
}while (t<=1002);
printf("%d",s);
return 0;
}

 



 

int t,a,b,c,s;
s=0;
for(t=100;t<=999;t++)
{   a=t/100;
    b=(t-a*100)/10;
    c=t-a*100-b*10;
    if (t==a*a*a+b*b*b+c*c*c)
    {printf("%d\n",t);
        s++;}
}
printf("水仙花数共有%d个",s);
 
return 0;
}

技术图片

 

#include <stdio.h>
int main()
{
int s,a,b,c;
s=0;
for(a=1;a<=3;a++)
for(b=a+1;b<=4;b++)
for(c=b+1;c<=5;c++)
{
    printf("%d%d%d  ",a,b,c);
    printf("%d%d%d  ",a,c,b);
    printf("%d%d%d  ",b,a,c);
    printf("%d%d%d  ",b,c,a);
    printf("%d%d%d  ",c,b,a);
    printf("%d%d%d\n",c,a,b);
    s+=6;
}
printf("%d",s);
return 0;
}

技术图片

实验3

标签:for   水仙花   技术   .com   mamicode   img   color   mic   stdio.h   

原文地址:https://www.cnblogs.com/p201821430041/p/10838447.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!