国产最新a级毛片无码专区_综合亚洲欧美日韩久久精品_日本成年片在线观看66_一本到九九av电影_一级毛片免费网站播放_国内精品久久人无码大片_国产人成视频99在线观看_欧美不卡在线一本二本_国产亚洲电影av_可以免费看黄色软件

知ing

C語言程序設計教程

楊路明 郭浩志 編 / 北京郵電大學出版社

紅塵陌上 上傳

查看本書

第3章 順序程序設計

1、輸入函數scanf的參數錯誤,應該為:scanf("%f",&k);

2、|1234?1234?|

3ff10

4、1,3,1

5、原字符串

???左邊加空格再加字符串本省,字符個數總和為5

6、scanf("%d,%d,%c,%c",&a1,&a2,&c1,&c2);

7、printf("a+b=%d\n",a+b);

???printf("a-b=%d\n",a-b);

???printf("a*b=%d\n",a*b);

???printf("a/b=%d\n",a/b);

???printf("(float)a/b=%f\n",(float)a/b);

???printf("a%b=%d\n",a%b);

8void?main()

???{

?????float?r;

?????float?s,c;

?????printf("please?input?the?number:");

?????scanf("%f",&r);

?????if(r>=0)

?????{

????????s?=?3.14*r*r;

????????c?=?2*3.14*r;

????????printf("s?=?%f,?c?=?%f\n",s,c);

?????}

?????else

printf("you?input?number?is?error!");

???}

9、void?main()

{

???int?n;

???printf("please?input?the?number:");

???scanf("%d",&n);

???if(n>=100?&&?n?<=?999)

??????printf("%d%d%d",n%10,(n/10)%10,n/100);

???else

printf("you?input?number?is?error!");

}

10、void?main()

{

???int?i,j,k;

???scanf("%d,%d,%d",&i,&j,&k);

???((i%2?!=?0?1:0)?+?(j%2?!=?0?1:0)+(k%2?!=?0?1:0))?==?2?printf("YES\n"):printf("NO\n");

}

11void?main()

{

??char?a;

??scanf("%c",&a);

??printf("%c,%c,%c",a-1,a,a+1);

??printf("%d,%d,%d",a-1,a,a+1);

}

12、void?main()

{

??float?a,b,c,s,Area;

??scanf("%f,%f,%f",&a,&b,&c);

??if(a+b?>?c?||?a+c?>?b?||?b+c?>a)

??{

???????s?=?(a+b+c)/2;

???????Area?=?sqrt(s*(s-a)*(s-b)*(s-c));

???????printf("%f\n",Area);

??}

??else

?????printf("you?input?the?number?is?error!\n");

}



第4章 選擇結構程序設計計

1?0

?

2?20

?

3:?????(x<30&&x>20)||(x<-100)

?

4:?***a=25,b=14,c=16***

?

5:?37

?

6:?if(a<=b)????printf("1");

else????????printf("2");

?

7

#include<stdio.h>

void?main()

{?char?a,b,t1,t2;

scanf("%c,%c",&a,&b);

t1=a>b?a:b;

t2=a<b?a:b;

if((t1-t2)%2==0)printf("%c,%c",a+1,b+1);

else??printf("%c,%c",a-1,b-1);

getch();

}

8、

#include<stdio.h>

void?main()

{?int?temp1=0,temp2=0,x,y,i=1;

printf("Please?input?(x,y):??");

scanf("%d,%d",&x,&y);

while((i*y)<=x)

{?if(x==(i*y))?{temp1=1;break;}

temp2=i;

i++;

}

if(temp1)

printf("%d?/?%d?=?%d",x,y,i);

else

printf("%d?/?%d--->?shang=%d,yushu=%d",x,y,temp2,x-y*temp2);

getch();

}

9、

#include<stdio.h>

void?main()

{?float?x,y,m=0,n=0;

scanf("%f,%f",&x,&y);

n=(x-2)*(x-2);

m=(y-2)*(y-2);

if((m+n)<=1)

printf("(%.3f,%.3f)In?the?yuan",x,y);

else

printf("(%.3f,%.3f)out?of?the?yuan",x,y);

getch();

}

10、

#include<stdio.h>

void?main()

{?int?temp=0,month,year;

printf("Please?input?(year,month):???");

scanf("%d,%d",&year,&month);

if((year%400==0)||(year%4==0&&year%100!=0))

temp=1;

if(month==2)

{?if(temp)printf("%d?year?%d?month?have?29?",year,month);

else?printf("%d?year?%d?month?have?28?",year,month);

}

else?if(month%2==0)

printf("%d?year?%d?month?have?30?",year,month);

else????printf("%d?year?%d?month?have?31?",year,month);

getch();

}

11、

switch(a/10)

{?case?5:m=4;break;

case?4:m=3;break;

case?3:m=2;break;

case?2:m=1;break;

default:m=5;?

}

12

方法一:

#include<stdio.h>

void?main()

{?int?x,y;

scanf("%d",&x);

if(x<0&&x>-5)

y=x-1;

else?if(x==0)

y=x;

else?if(x>0&&x<8)

y=x+1;

printf("%d",y);

getch();

}

方法二:

#include<stdio.h>

void?main()

{?int?x,y;

scanf("%d",&x);

if(x<8&&x>-5)

{?if(x==0)y=x;

else?if(x>0&&x<8)????y=y=x+1;

else?y=x-1;

printf("%d",y);

}

else????printf("Input?error!!!");

getch();

}

方法三:

#include<stdio.h>

void?main()

{?int?x,y,i;

scanf("%d",&x);

if(x<8&&x>-5)

{?if(x==0)i=1;

else?if(x>0&&x<8)???i=2;

else?i=3;

}

else????i=4;

switch(i)

{?case?1:y=x;printf("%d",y);break;

case?2:y=x+1;printf("%d",y);break;

case?3:y=x-1;printf("%d",y);break;

case?4:printf("Input?error!!");break;

}getch();

}



查看更多