其他分享
首页 > 其他分享> > 实验三

实验三

作者:互联网


 1.#include<stdio.h>
int main(){
 int a = 22,i,sum = 0;
 for(i = 0;i < 50;i++){
 sum = sum + a;
 a += 20;
 }
 printf("%d",sum);
}
#include<stdio.h>
int main(){
 int a = 22,i,sum = 0;
 while(a != 1022 ){
 sum += a;
 a += 20;
 }
 printf("%d",sum);
}
#include<stdio.h>
int main(){
 int a = 22,i,sum = 0;
 do{
 sum += a;
 a += 20;
 }
 while(a != 1022 );
 printf("%d",sum);
}
2.#include<stdio.h>
int main(){
 int a = 100;
 int b,c,d;
 for(a = 100;a < 1000;a++){
  b = a/100;
  c = a/10 - 10*b;
  d = a- 100*b - 10*c;

 if(b*b*b+d*d*d+c*c*c ==a)
   printf("%d ",a);
 }
}
3.#include<stdio.h>
int main(){
 int a = 1,b = 1,c = 1,sum = 0;
 for(a = 1;a <= 5;a++)
  for(b = 1;b <= 5;b++)
   for(c = 1;c <= 5;c++){
    if(a != b && b != c &&a !=c){
    printf("%d ",a*100+b*10+c);
    sum++;
    }
   }
   printf("%d",sum);
}

标签:int,sum,实验,includeint,printf,100,main
来源: https://www.cnblogs.com/p201821440021/p/10750016.html