实验三

#include<stdio.h>

int main()

{

         long int a,s;

         s=0;

         for(a=22;a<=1002;a+=20)

         {

                   s+=a;

         }

         printf("s=%d",s);

         return 0;

}

 

#include<stdio.h>

int main()

{

         long int a,s;

         a=22;

         s=22;

         while(a<1002)

         {

                   a+=20;

                   s+=a;

         }

 

 

         printf("s=%d",s);

         return 0;

}

 

#include<stdio.h>

int main()

{

         long int a,s;

         a=22;

         s=0;

         do{

                   s+=a;

                   a+=20;

         }while(a<=1002);

         printf("s=%d",s);

         return 0;

}

 

#include<stdio.h>

#include<math.h>

int main()

{

         int a,a1,a10,a100,b,i;

         i=0;

         for(a=100;a<=999;a++)

         {

                   a100=a/100;

                   a10=(a-(100*a100))/10;

                   a1=a-(100*a100)-(10*a10);

                   b=pow(a1,3)+pow(a10,3)+pow(a100,3);

                   while(a==b)

                   {

                            printf("%d\n",a);

                            i++;

                            break;

                   }

         }

         printf("一共有%d个水仙花数",i);

         return 0;

}

 

 

#include<stdio.h>

int main()

{

         int a[5]={1,2,3,4,5};

         int i,j,k,b;

         b=0;

         for(i=0;i<5;i++) 

                   for(j=0;j<5;j++)

                            for(k=0;k<5;k++)  

                            {

                                     if(j!=i&&k!=i&&k!=j)   

                                     {

                                               printf("%d%d%d\n",a[i],a[j],a[k]);

                                               b++;

                                     }   

                            }

                            printf("一共有%d个数",b);

                            return 0;

}

 

 

 

posted @ 2019-05-06 15:16  p201821440011  阅读(134)  评论(0编辑  收藏  举报