A - 数列求和3
<https://acm.sdut.edu.cn/onlinejudge2/index.php/Home/Contest/contestproblem/cid/2603/pid/4288>

注意while循环的条件

 

    #include<stdio.h> int main() { int n,sum; scanf("%d",&n); int i =1; sum =
0; while(i<=n){ sum+=i; i++; } printf("%d\n",sum); return 0; }
 
数位数
#include<stdio.h> int main() { long int x; int n = 0;//n用来记录位数
scanf("%ld",&x); if(x == 0)//特殊情况单独判定 printf("%d\n",n); else{ while(x/1 != 0){
n++; x /= 10; } printf("%d",n); } return 0; }
C - N^3问题
<https://acm.sdut.edu.cn/onlinejudge2/index.php/Home/Contest/contestproblem/cid/2603/pid/2245>
#include<stdio.h> int main() { int n; scanf("%d",&n); int a; a = n*n*n; int b;
int sum = 0; while(a/1 !=0){ b = a%10;//用b存储a的各位数字 sum += b*b*b; a = a/10; }
printf("%d\n",sum); return 0; }
 
D - 小树快长高
<https://acm.sdut.edu.cn/onlinejudge2/index.php/Home/Contest/contestproblem/cid/2603/pid/4287>

A题的升级版

本题设置雷区
#include<stdio.h> int main() { int n,m,k,i; int sum = 0; scanf("%d %d
%d",&n,&m,&k); i = n; while(i<=m){ sum++; i = i+k; }//大约在附近,我埋了个雷,很容易解决
printf("%d\n",sum); return 0; }
 


E - 偶数数位求和
<https://acm.sdut.edu.cn/onlinejudge2/index.php/Home/Contest/contestproblem/cid/2603/pid/4286>

The Updation of Problem A :

choose the even number to add up

so,need to use the “if ” framework


F - 小粉的难题
<https://acm.sdut.edu.cn/onlinejudge2/index.php/Home/Contest/contestproblem/cid/2603/pid/4280>

Althought it is the updation of Problem A

if the chosen number is equal to the one asked

the sum is added

 

 
G - A+B for Input-Output Practice (I)
<https://acm.sdut.edu.cn/onlinejudge2/index.php/Home/Contest/contestproblem/cid/2603/pid/1010>

多组输入 单组相加

 
#include<stdio.h> int main() { int a,b; while(scanf("%d %d",&a,&b)!=EOF){
//while(~scanf("%d %d",&a,&b))也可 printf("%d\n",a+b); } return 0; }
 


 


H - A+B for Input-Output Practice (III)
<https://acm.sdut.edu.cn/onlinejudge2/index.php/Home/Contest/contestproblem/cid/2603/pid/1012>

G题的Plus 在while内加入和判断语句 即 while(scanf'    && a!=0&&b!=0)

 
I - A+B for Input-Output Practice (VII)
<https://acm.sdut.edu.cn/onlinejudge2/index.php/Home/Contest/contestproblem/cid/2603/pid/1016>

G题的another plus 在printf行内多加个换行


K - 优越数
<https://acm.sdut.edu.cn/onlinejudge2/index.php/Home/Contest/contestproblem/cid/2603/pid/1442>

按照题设做就行

同样设置雷区

 
#include<stdio.h> int main() { int n; scanf("%d",&n); while(n--){ int a,b,c;
scanf("%d %d %d",&a,&b,&c); int flag = 0;//设定标记符,一方面省存储空间和读取时间,另一方面,方便计算 int
ave; ave = (a+b+c)/3; if(ave<a){ falg++; } if(ave<b){ flag++; } if(ave<c){
flag++; } if(flag>1)printf("Yes\n"); else printf("No\n"); } return 0; }
N - 计算球体积
<https://acm.sdut.edu.cn/onlinejudge2/index.php/Home/Contest/contestproblem/cid/2603/pid/1235>
#include<stdio.h> #define PI 3.1415927 int main() { double r,v;
while(~scanf("%lf",&r)){ v = 4*PI*r*r*r/3; printf("%.3lf\n",v); } return 0; }