jiangguo2
[i=s] 本帖最后由 jiangguo2

本帖最后由 jiangguo2 于 2013-5-5 15:42 编辑

参赛ID:jiangguoer

参与类型:A

答案:

/*8.到第10天早上想再吃时,见只剩下一个桃子了。求第一天共摘了多少。 */

#include<stdio.h>

int main(void){

int day=10,peach=1;

for(;day>1;day--){

peach+=1;

peach*=2;

}

printf("the monkey got %d peaches in total.\n",peach);

return 0;

}

/*7*/

#include<stdio.h>

int main(void){

float in,out=0;

printf("How much did you get?\n");

scanf("%f",&in);

if(in<=100000)out=0.1*in;

else if(in<=200000){in-=100000;out=10000+0.075*in;}

else if(in<=400000){in-=200000;out=17500+0.05*in;}

else if(in<=600000){in-=400000;out=27500+0.03*in;}

else if(in<=1000000){in-=600000;out=33500+0.015*in;}

else{in-=1000000;out=39500+0.01*in;}

printf("You got %f.\n",out);

return 0;

}

/*4*/

#include<stdio.h>

int main(void){

int a,b,c,d,e;

a=10;

b=a+2;

c=b+2;

d=c+2;

e=d+2;

printf("%d",e);

return 0;

}

/*output:

18*/

/*3.题目:两个乒乓球队进行比赛,各出三人。甲队为a,b,c三人,乙队为x,y,z三人。已抽签决定比赛名单。

有人向队员打听比赛的名单。a说他不和x比,c说他不和x,z比,请编程序找出三队赛手的名单。*/

#include<stdio.h>

int main(void)

{

int a=1,b=2,c=3;

int x,y,z;

char aa=a,bb=b,cc=c;

int sum=6;

x=sum-a-c;

sum-=x;

z=sum-c;

sum-=z;

y=sum;

printf("x with ");P(x);

printf("y with ");P(y);

printf("z with ");P(z);

return 0;

}

int P(int m){

char a='a',b='b',c='c';

if(m==1)printf("%c\n",a);

else if(m==2)printf("%c\n",b);

else printf("%c\n",c);

return 0;

}

/*output:

x with b

y with c

z with a*/

/*2.*/

#include<stdio.h>

int main(void)

{

int time=2;

float sum=100,high=50;

for(;time<=10;time++){

sum+=2*high;

high=high/2;

}

printf("%f\n",sum);

return 0;

}

/*output:

299.609375*/

/*1.*/

#include<stdio.h>

int main(void)

{

int a=1,b=1;

int count=0;

for(;a<=1000;a++){

while(b<a){

if(a%b==0)count+=b;

b++;

}

if(a==count)printf("%d\n",a);

count=0;

b=1;

}

return 0;

}

/*output:

6

28

496*/