# 算法笔记codeup-Contest100000568

0
11

A

```#include <stdio.h>
int main()
{
int a=100;
int sum=0;
while(a)
{
sum=sum+a;
a--;
}
printf("%d",sum);
return 0;
}```

B 差不多

C

```#include <stdio.h>
int main()
{
int a=100;
int sum=0;
for (;a>=1;a--) {
/* code */
sum+=a;
}
printf("%d",sum);
}```

D

```#include <stdio.h>
int main()
{
int a=0;
int sum=0;
scanf("%d",&a);
for (;a>=1;a--) {
/* code */
sum+=a;
}
printf("%d",sum);
}```

E

```#include <stdio.h>
int main()
{
int a=1;
int sum=0;
for (;a<=10000;a++) {
/* code */
sum+=a;
if(sum>1000)
break;
}
printf("%d",a);
}```

F

``` #include <stdio.h>

int main()
{
int i=0;
for(i=1;i<=4;i++)
{
printf("%3d",1*i);
printf("%3d",2*i);
printf("%3d",3*i);
printf("%3d",4*i);
printf("%3d\n",5*i);
}

} ```

G

```#include<stdio.h>
#include<math.h>
int main()
{
int sign=1;
double pi=0.0,n=1.0,term=1.0;
while(fabs(term)>=1e-6)
{
pi=pi+term;
n=n+2;
sign=-sign;
term=sign/n;
}
pi=pi*4;
printf("PI=%10.8f\n",pi);
return 0;
}```

H

```#include <stdio.h>
#include <math.h>
int main()
{
int A=1;
int B=1;
int C=0;
int count=0;
int init=0;
int chushu=0;
int yushu=0;

scanf("%d",&count);
chushu=count/3;
yushu=count%3;
if(count==1||count==2)
{
printf("1");
}
else{
for(;init<chushu;init++)
{
C=A+B;
A=B+C;
B=C+A;
}
switch(yushu)
{
case 0:
printf("%d",C);
break;
case 1:
printf("%d",A);
break;
case 2:
printf("%d",B);
break;
}
}

} ```

I

```#include <stdio.h>
#include <math.h>
int main()
{
double A=1.0;
double B=2.0;
int count=20;
int temp=0;
int init=0;
double sum=0.0;

for(;init<20;init++)
{
sum+=B/A;
temp=B;
B=A+B;
A=temp;
}

printf("%.6lf",sum);

} ```

<