版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1.5#include
<stdio.h>void
main(
){printf(“******************************\n”);printf(“\n”);printf(“□□□□□□□Very
good!\n”);printf(“\n”);printf(“******************************\n”);}電信學(xué)院蔣玉蓮1第一章習(xí)題1.6方法一:#include
<stdio.h>void
main(){int
a,b,c,max;scanf(“%d,%d,%d”,&a,&b,&c);max=a;if(max<b)max=b;if(max<c)max=c;printf(“The
max
is
%d”,
max);}電信學(xué)院蔣玉蓮2方法二:#include
<stdio.h>void
main(){int
max(int
x,
int
y);int
a,b,c,d,e,f;scanf("%d,%d,%d",&a,&b,&c);d=max(a,b);e=max(a,c);f=max(d,e);printf("The
max
is
%d\n",
f);}int
max(int
x,
int
y){int
z;if
(x>y)
z=x;else
z=y;return
z;}電信學(xué)院蔣玉蓮3習(xí)題3.7電信學(xué)院蔣玉蓮4#include<stdio.h>void
main(
){char
c1=‘c’,c2=‘h’,c3=‘i’,c4=‘n’,c5=‘a(chǎn)’;c1+=4;c2+=4;c3+=4;c4+=4;c5+=4;printf(“the
cipher
is:
%c
%c
%c
%c
%c\n”,c1,c2,c3,c4,}第三章習(xí)題習(xí)題3.9(1)
x+a%3*(int)(x+y)%2/4設(shè)x=2.5,a=7,y=4.7答案為2.5電信學(xué)院蔣玉蓮5設(shè)a=2,b=3,x=3.5,y=(2)(float)(a+b)/2+(int)x%(int)y答案為3.5習(xí)題3.12(1)
a=24(2)
a=10(3)
a=60(4)
a=0(5)
a=0(6)
a=0電信學(xué)院蔣玉蓮64.4#include<stdio.h>void
main(){int
a,
b,
c;long
int
u,
n;float
x,
y,
z;char
c1,
c2;a=3;
b=4;
c=5;x=1.2;
y=2.4;
z=
-3.6;u=51274;
n=128765;c1=‘a(chǎn)’;
c2=‘b’;printf(“a=%2d□□b=%2d
□□
c=%2d
\n”,
a,
b,
c
);printf(“x=%8.6f,
y=%8.6f,
z=%9.6f\n”,
x,
y,
z);電信學(xué)院蔣玉蓮7第四章習(xí)題printf(“x+y=%5.2f
□□
y+z=%5.2f
□□z+x=%5.2f\n”,x+y,y+z,z+x);printf(“u=%6ld
□□n=%9ld\n”,u,n);printf(“c1=‘%c’
□or
□%d(ASCII)\n”,c1,c1);printf(“c2=‘%c’
□or
□%d(ASCII)\n”,c2,c2);}電信學(xué)院蔣玉蓮8習(xí)題4.8:圓半徑r=1.5,圓柱高h(yuǎn)=3,求圓周長(zhǎng)、圓面積、圓球面積、圓球體積、圓柱體積。輸出的結(jié)果取小數(shù)點(diǎn)后2位數(shù)字。#include<stdio.h>void
main(){float
pi,
h,
r,
l,
s,
sq,
vq,
vz;pi=3.1415926;
printf(“input
r,
h:\n”);scanf(“%f,%f”,
&r,
&h);電信學(xué)院蔣玉蓮9l=2*pi*r;
s=pi*r*r;vq=4.3/3.0*pi*r*r*r;sq=4*pi*r*r;vz=pi*r*r*h;printf(“the
perimeter
of
the
circle:
l=%6.2f\n”,l);printf(“the
area
of
the
circle:
s=%6.2f\n”,s);printf(“the
face
area
of
the
pallet:
sq=%6.2f\n”,sq)printf(“the
cubage
of
the
pallet:
vq=%6.2f\n”,vq);printf(“the
cubage
of
the
column:
sz=%6.2f\n”,sz);}習(xí)題4.9:#include<stdio.h>void
main(){float
c,f;printf(“input
the
fahrenheit:\n”);scanf(“%f”,
&f);c=(5.0/9.0)*(f-32);printf(“the
centigrade
:%5.2f\n”,c);}電信學(xué)院蔣玉蓮10第五章習(xí)題電信學(xué)院蔣玉蓮11習(xí)題5.3:設(shè)a=3,b=4,c=5。(1)0(2)1(3)(5)11(4)0習(xí)題5.4#include<stdio.h>void
main(){int
a,b,c;printf(“please
input
a,b,c:”);scanf(“%d,%d,%d”,&a,&b,&c);if(a<b){if(b<c)printf(“max=%d\n”,c);elseprintf(“max=%d\n”,b);}else
if
(a<c)printf(“max=%d\n”,c);elseprintf(“max=%d\n”
a);}12習(xí)題5.5#include<stdio.h>void
main(){int
x,y;printf(“please
input
x:”);scanf(“%d”,
&x);if
(x<1){
y=x;
printf(“x=%d,y=x=%d\n”,x,y);}else
if
(x<10){
y=2*x-1;
printf(“x=%d,y=
2*x-1
=%d\n”,x,y);}else{y=3*x-11;
printf(“x=%d,y=
3*x-11
=%d\n”,x,y);}}電信學(xué)院蔣玉蓮
13習(xí)題5.6#include<stdio.h>void
main(){float
score;int
grade;printf(“Input
a
score(0~100):
”);scanf(“%f”,
&score);grade
=
score/10;switch
(grade){·
case
10:·case
9:
printf(“grade=A\n”);
break;14·
case
8:
printf("grade=B\n");
break;15case
7:
printf("grade=C\n");
break;case
6:
printf("grade=D\n");
break;case
5:case
4:case
3:case
2:case
1:case
0:
printf(“grade=E\n”);}}·程序運(yùn)行情況如下:·Input
a
score(0~100):
85.5↙·grade=B電信學(xué)院蔣玉蓮習(xí)題5.7#include<stdio.h>void
main(){long
int
num;int
indiv,
ten,
hundred,
thousand,
ten_thousand,
place;scanf(“%ld”,&num);if(num>9999)place=5;else
if(num>999)place=4;else
if(num>99)place=3;else
if(num>9)place=2;elseplace=1;printf(“place=%d\n”,
place);16printf(“每位數(shù)字為:”);ten_thousand=num/10000;thousand=(num-
ten_thousand*10000)/1000;hundred=
(num-
ten_thousand*10000-thousand*1000)/100;ten=
(num-
ten_thousand*10000-thousand*1000-hundred*10indiv=
num-
ten_thousand*10000-thousand*1000-hundred*1ten*10;17電信學(xué)院蔣玉蓮switch(place){case
5:
printf(“%d,%d,%d,%d,%d”,
ten_thousand,thousand,hundred,
ten,indiv);printf(“逆序輸出為:%d,%d,%d,%d,%d\n”,indiv,ten,hundred,
thousand,
ten_thousand);break;case
4:
printf(“%d,%d,%d,%d”,
thousand,
hundred,ten,indiv);printf(“逆序輸出為:%d,%d,%d,%d\n”,indiv,tenhundred,thousand);break;case
3:printf(“%d,%d,%d”,hundred,ten,indiv);printf(“逆序輸出為:%d,%d,%d\n”,indiv,ten,hundred);break;case
2:
printf(“%d,%d”,
ten,indiv);printf(“逆序輸出為:%d,%d\n”,indiv,ten);breacase
1:
printf(“%d”,
indiv);}}18printf(“逆序輸出為:%d\n”,indiv);電信學(xué)院蔣玉蓮習(xí)題5.8
用if編程實(shí)現(xiàn)#include<stdio.h>void
main(){long
i;float
bonus,bon1,bon2,bon4,bon6,bon10;bon1=100000*0.1;bon2=bon1+100000*0.075;bon4=bon2+200000*0.05;bon6=bon4+200000*0.03;bon10=bon6+400000*0.015;printf(“please
input
the
profit:”);scanf(“%ld”,&i);電信學(xué)院蔣玉蓮19if
(i<=100000)bonus=i*0.1;else
if
(i<=200000)bonus=bon1+(i-100000)*0.075;else
if
(i<=400000)bonus=bon2+(i-200000)*0.05;else
if
(i<=600000)bonus=bon4+(i-400000)*0.03;else
if
(i<=1000000)bonus=bon6+(i-600000)*0.015;elsebonus=bon10+(i-1000000)*0.01;printf(“bonus=%f”,bonus);}電信學(xué)院蔣玉蓮20習(xí)題5.9#include<stdio.h>void
main(){int
a,b,c,d,t;printf(“please
input
a,b,c,d:”);scanf(“%d,%d,%d,%d”,
&a,
&
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2026年智能門(mén)窗Matter模塊項(xiàng)目評(píng)估報(bào)告
- 2026年量子隨機(jī)數(shù)芯片項(xiàng)目可行性研究報(bào)告
- 2026年智能電烤箱項(xiàng)目評(píng)估報(bào)告
- 2026年智能胎壓監(jiān)測(cè)器項(xiàng)目公司成立分析報(bào)告
- 教師教育教學(xué)工作制度
- 幼兒院幼兒教育與師資培訓(xùn)制度
- 音樂(lè)可視化交互設(shè)計(jì)技巧課程設(shè)計(jì)
- 病人就醫(yī)管理課程設(shè)計(jì)
- 桂林漓佳16000噸銅基新材料生產(chǎn)線技術(shù)升級(jí)改造項(xiàng)目環(huán)境影響報(bào)告表
- 國(guó)際合作項(xiàng)目資金管理承諾函9篇范文
- 物業(yè)維修工安全培訓(xùn)課件
- 戶外電源技術(shù)講解
- 一年級(jí)體育課題申報(bào)書(shū)
- 墻面夾芯板安裝施工方案
- 六年級(jí)語(yǔ)文閱讀理解之托物言志(知識(shí)梳理技法點(diǎn)撥例文分析)(含答案)
- 鈑金供應(yīng)商管理辦法
- 煤礦自救器使用課件
- 《油氣管道無(wú)人機(jī)智能巡檢系統(tǒng)技術(shù)管理規(guī)范》
- 2025電力公司員工聘用合同
- 運(yùn)輸公司安全教育培訓(xùn)記錄范文
- 2025年貴州省委黨校在職研究生招生考試(中共黨史)歷年參考題庫(kù)含答案詳解(5卷)
評(píng)論
0/150
提交評(píng)論