17-11-10

作业一:累加求和

#include
int main()
{
  int i=1;
  int num=0;
  do{
        num=num+i;
        i++;
    }while(i<=100)
     printf("1+......+%d\n=%d\n,"i-1,num):
    return 0;
}
作业二:累加求和

include

int main()
{
int i=1;
int num=0;
do{
num=num+i;
i=i+2;
}while(i<100);
printf("%d",num);
return 0;
}

作业三:累加求和

include

int main()
{
int i=2;
int num=0;
do{
num=num+i;
i=i+2;
}while(i<=100);
printf("%d",num);
return 0;
}

作业四:输出求和

include

int main()
{
int a,b,c;
double average;
printf("请输入一个整数");
scanf("%d",&a);
if(a<=21){
printf("yes->1");
}else{
printf("no->0");
}
printf("请输入一个整数");
scanf("%d",&b);
if(b<=22){
printf("yes->1");
}else{
printf("no->0");
}
printf("请输入一个整数");
scanf("%d",&c);
if(c!=30){
printf("yes->1");
}else{
printf("no->0");
}
printf("a+b+c=%d",21+22+30);
average=(a+b+c)/3;
printf("%f",average);
return 0;
}

作业五:

include

int main()
{
int a=0;
int b=0;
int sum=0;
scanf("%d %d",&a,&b);
do{
sum=sum+a;
a++;
} while(a<=b);
printf("大于等于%d小于等于%d的整数之和为:%d",a,b,sum);
return 0;
}

作业五(5.2)

include

int main()
{
int a=0;
int b=0;
int sum=0;
scanf("%d %d",&a,&b);
do{
sum=sum+b;
b++;
} while(b<=a);
printf("大于等于%d小于等于%d的整数之和为:%d",b,a,sum);
return 0;
}

你可能感兴趣的:(17-11-10)