C-Primer-Plus(第五版)中文版课后习题答案_第1页
C-Primer-Plus(第五版)中文版课后习题答案_第2页
C-Primer-Plus(第五版)中文版课后习题答案_第3页
C-Primer-Plus(第五版)中文版课后习题答案_第4页
C-Primer-Plus(第五版)中文版课后习题答案_第5页
已阅读5页,还剩107页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

Chapter2

PE2-1

/*ProgrammingExercise2-1*/

^include<stdio.h>

intmain(void)

(

printf(,zAntonBruckner\n");

printf(/zAnton\nBruckner\n,/);

printf("Anton");

printf("Bruckner\n");

return0;

)

PE2-3

/*ProgrammingExercise2-3*/

#include<stdio.h>

intmain(void)

(

intageyears;/*ageinyears*/

intagedays;/*ageindays*/

/*largeagesmayrequirethelongtype*/

ageyears=44;

agedays=365*ageyears;

printf("Anageof%dyearsis%ddays.\n/z,ageyears,agedays);

return0;

)

PE2-4

/*ProgrammingExercise2-4*/

^include<stdio.h>

voidjolly(void);

voiddeny(void);

intmain(void)

jollyO;

jollyO;

jollyO;

deny();

return0;

)

voidjolly(void)

(

printf("Forhe,sajollygoodfellow!Xn^);

)

voiddeny(void)

(

printf("Whichnobodycandeny!\n");

)

PE2-5

/*ProgrammingExercise2-5*/

^include<stdio.h>

intmain(void)

(

inttoes;

toes=10;

printf(^toes=%d\n",toes);

printf("Twicetoes=%d\n",2*toes);

printf(^toessquared=%d\n",toes*toes);

return0;

)

/*orcreatetwomorevariables,setthemto2*toesandtoes*toes

PE2-7

/*ProgrammingExercise2-7*/

#include<stdio.h>

voidone_three(void);

voidtwo(void);

intmain(void)

(

printf(^startingnow:\n");

one_three();

printf("done!\n");

return0;

)

voidone_three(void)

(

printf("one'n");

two();

printf("three'n");

)

voidtwo(void)

(

printf("two'n");

)

Chapter3

PE3-2

/*ProgrammingExercise3-2*/

ttinclude<stdio.h>

intmain(void)

(

intascii;

printf("EnteranASCIIcode:");

scanf&ascii);

printf(〃%distheASCIIcodefor%c.\n\ascii,ascii);

return0;

)

PE3-4

/*ProgrammingExercise3-4*/

^include<stdio.h>

intmain(void)

(

floatnum;

printf("Enterafloating-pointvalue:");

scanf&num);

printf(^fixed-pointnotation:num);

printf(^exponentialnotation:%e\n”,num);

return0;

)

PE3-6

/*ProgrammingExercise3-6*/

#include<stdio.h>

intmain(void)

(

floatmass_mol=3.0e-23;/*massofwatermoleculeingrams*/

floatmass_qt=950;/*massofquartofwateringrams*/

floatquarts;

floatmolecules;

printf("Enterthenumberofquartsofwater:〃);

scanf&quarts);

molecules=quarts*mass_qt/mass_mol;

printf("%fquartsofwatercontain%emolecules.\n/z,quarts,

molecules);

return0;

)

Chapter4

PE4-1

/*ProgrammingExercise4-1*/

^include<stdio.h>

intmain(void)

(

charfname[40];

charIname[40];

printf("Enteryourfirstname:");

scanffname);

printf("Enteryourlastname:");

scanfIname);

printf("%s,%s\n”,Iname,fname);

return0;

)

PE4-4

/*ProgrammingExercise4-4*/

^include<stdio.h>

intmain(void)

(

floatheight;

charname[40];

printf("Enteryourheightininches:");

scanf&height);

printf("Enteryourname:");

scanfname);

printf("%s,youare%.3ffeettall\nz,,name,height/12.0);

return0;

)

PE4-6

/*ProgrammingExercise4-6*/

^include<stdio.h>

^include<float.h>

intmain(void)

floatot_f=1.0/3.0;

doubleot_d=1.0/3.0;

printffloatvalues:");

printf(^%.4f%.12f%.ot_f,ot_f,ot__f);

printf(^doublevalues:");

printf(^%.4f%.12f%.16f\n",ot_d,ot_d,ot_d);

printf("FLT_DIG:%d\n〃,FLT_DIG7;

printfCDBL__DIG:%d\n〃,DBL_DIG);

return0;

Chapter5

PE5-1

/*ProgrammingExercise5-1*/

^include<stdio.h>

intmain(void)

{

constintminperhour=60;

intminutes,hours,mins;

printf("Enterthenumberofminutestoconvert:");

scanf&minutes);

while(minutes>0)

{

hours=minutes/minperhour;

mins=minutes%minperhour;

printf("%dminutes=%dhours,%dminutes'n",minutes,hours,

mins);

printf("Enternextminutesvalue(0toquit):");

scanf&minutes);

)

printf("Bye\n");

return0;

)

PE5-3

/*ProgrammingExercise5_3*/

#include<stdio.h>

intmain(void)

(

constintdaysperweek=7;

intdays,weeks,day_rem;

printf("Enterthenumberofdays:");

scanfMays);

weeks=days/daysperweek;

day_rem=days%daysperweek;

printf("%ddaysare%dweeksand%ddays.\n〃,days,weeks,day_rem);

return0;

)

PE5-5

/*ProgrammingExercise5-5*/

#include<stdio.h>

intmain(void)/*findssumoffirstnintegers*/

(

intcount,sum;

intn;

printf("Entertheupperlimit:");

scanf&n);

count=0;

sum=0;

while(count++<n)

sum=sum+count;

printf("sum二%d\n”,sum);

return0;

)

PE5-7

/*ProgrammingExercise5-7*/

^include<stdio.h>

voidshowCube(doublex);

intmain(void)/*findscubeofenterednumber*/

(

doubleval;

printf("Enterafloating-pointvalue:");

scanf&val);

showCube(val);

return0;

)

voidshowCube(doublex)

(

printf("Thecubeof%eis%e.\n\x,x*x*x);

Chapter6

PE6-1

/*pe6-l.c*/

/*thisimplementationassumesthecharactercodes*/

/*aresequential,astheyareinASCII.*/

#include<stdio.h>

^defineSIZE26

intmain(void)

(

charlease[SIZE];

inti;

for(i=0;i<SIZE;i++)

lcase[i]='a'+i;

for(i=0;i<SIZE;i++)

printflease[i]);

printf("\n〃);

return0;

PE6-3

/*pe6-3.c*/

/*thisimplementationassumesthecharactercodes*/

/*aresequential,astheyareinASCII.*/

^include<stdio.h>

intmain(void)

(

charlet='F';

charstart;

charend;

for(end=let;end>='A';end一)

(

for(start=let;start>=end;start一)

printfstart);

printf("\n〃);

}

return0;

)

PE6-5

/*pe6-5.c*/

#include<stdio.h>

intmain(void)

(

intlower,upper,index;

intsquare,cube;

printf("Enterstartinginteger:");

scanf(〃%d”,&lower);

printf("Enterendinginteger:");

scanf&upper);

printf("%5s%10s%15s\n","num","square","cube");

for(index=lower;index<=upper;index++)

(

square=index*index;

cube=index*square;

printf("%5d%10d%15d\n”,index,square,cube);

)

return0;

)

PE6-7

/*pe6-7.c*/

#include<stdio.h>

intmain(void)

(

doublen,m;

doubleres;

printf("Enterapairofnumbers:");

while(scanf("%lf%lf”,&n,&m)==2)

(

res=(n-m)/(n*m);

printfC(%.3g-%.3g)/(%.3g*%.3g)=%.5g\n”,n,m,n,m,res);

printf("Enternextpair(non-numerictoquit):");

)

return0;

}

PE6-10

/*pe6-10.c*/

^include<stdio.h>

#defineSIZE8

intmain(void)

(

intvals[SIZE];

inti;

printf("Pleaseenter%dintegers.\n,z,SIZE);

for(i=0;i<SIZE;i++)

scanf("%d〃,&vals[i]);

printf("Here,inreverseorder,arethevaluesyouentered:\n,z);

for(i=SIZE-1;i>0;i-)

printfC"%d",vals[i]);

printf("\n");

return0;

PE6-12

/*pe6-12.c*/

I*Thisversionstartswiththe0power*/

^include<stdio.h>

itdefineSIZE8

intmain(void)

(

inttwopows[SIZE];

inti;

intvalue=1;/*2tothe0*/

for(i=0;i<SIZE;i++)

(

twopows[i]=value;

value*=2;

)

i=0;

do

(

printf(,z%d〃,twopows[i]);

i++;

}while(i<SIZE);

printf("\n");

return0;

)

PE6-13

/*pe-13.c*/

/*ProgrammingExercise6-13*/

^include<stdio.h>

#defineSIZE8

intmain(void)

(

doublearr[SIZE];

doublearr_cumul[SIZE];

inti;

printf("Enter%dnumbers:\n^,SIZE);

for(i=0;i<SIZE;i++)

(

printf("value#%d:",i+1);

scanf&arr[i]);

/*orscanfarr+i);*/

)

arr_cumul[0]=arr[0];/*setfirstelement*/

for(i=1;i<SIZE;i++)

arr_cumul[i]=arr_cumul[i-1]+arr[i];

for(i=0;i<SIZE;i++)

printf("%8g”,arr[i]);

printf(〃\n");

for(i=0;i<SIZE;i++)

printf("%8g",arr__cumul[i]);

printf(〃\n〃);

return0;

)

PE6-15

/*pe6-15.c*/

^include<stdio.h>

#defineRATE_SIMP0.10

#defineRATE_C0MP0.05

#defineINIT_AMT100.0

intmain(void)

doubledaphne=INIT_AMT;

doubledeidre=INIT__AMT;

intyears=0;

while(deidre<=daphne)

daphne+=RATE_SIMP*INIT_AMT;

deidre+=RATE_C0MP*deidre;

++years;

}

printf(^Investmentvaluesafter%dyears:\n/,,years);

printf("Daphne:$%.2f\n”,daphne);

printf("Deidre:$%.2f\nz,,deidre);

return0;

)

Chapter7

PE7-1

/*ProgrammingExercise7-1*/

#include<stdio.h>

intmain(void)

(

charch;

intsp_ct=0;

intnl_ct=0;

intother=0;

while((ch=getchar())!='#')

(

if(ch=='')

sp_ct++;

elseif(ch=='\n')

nl_ct++;

else

other++;

)

printf(^spaces:%d,newlines:%d,others:%d\n”,sp_ct,nl_ct,

other);

return0;

)

PE7-3

/*ProgrammingExercise7_3*/

#include<stdio.h>

intmain(void)

(

intn;

doublesumeven=0.0;

intct_even=0;

doublesumodd=0.0;

intct_odd=0;

while(scanf("%d〃,&n)==1&&n!=0)

(

if(n%2=1)

(

sumodd+=n;

++ct__odd;

)

else

(

sumeven+=n;

++ct_even;

)

)

printf("Numberofevens:%d”,ct_even);

if(ct_even>0)

printf("average:%g”,sumeven/ct_even);

putchar('\n);

printf("Numberofodds:%d”,ct_odd);

if(ct_odd>0)

printfCaverage:%g”,sumodd/ct_odd);

putchar('\n);

printf("\ndone\n");

return0;

)

PE7-5

/*ProgrammingExercise7-5*/

^include<stdio.h>

intmain(void)

(

charch;

intctl=0;

intct2=0;

while((ch=getchar())!='#')

switch(ch)

(

case:putchar('!')

++ctl;

break;

case'!':putchar('!')

putchar('!')

++ct2;

break;

default:putchar(ch);

)

printf(z,%dreplacementsof.with!\n",ctl);

printf(,z%dreplacementsof!with!!\n",ct2);

return0;

)

PE7-7

/*ProgrammingExercise7-7*/

^include<stdio.h>

^defineBASEPAY10/*$10perhour*/

#defineBASEHRS40/*hoursatbasepay*/

^defineOVERTIME1.5/*1.5time*/

^defineAMT1300/*1stratetier*/

ttdefineAMT2150/*2stratetier*/

^defineRATE10.15/*ratefor1sttier*/

^defineRATE20.20/*ratefor2ndtier*/

#defineRATE30.25/*ratefor3rdtier*/

intmain(void)

(

doublehours;

doublegross;

doublenet;

doubletaxes;

printf("Enterthenumberofhoursworkedthisweek:");

scanf("%lf”,&hours);

if(hours<=BASEHRS)

gross=hours*BASEPAY;

else

gross=BASEHRS*BASEPAY+(hours-BASEHRS)*BASEPAY*

OVERTIME;

if(gross<=AMT1)

taxes=gross*RATE1;

elseif(gross<=AMT1+AMT2)

taxes=AMT1*RATE1+(gross-AMT1)*RATE2;

else

taxes=AMT1*RATE1+AMT2*RATE2+(gross-AMT1-AMT2)*

RATE3;

net=gross-taxes;

printf("gross:$%.2f;taxes:$%.2f;net:$%・2f\n”,gross,taxes,

net);

return0;

)

PE7-9

/*ProgrammmingExercise7-9*/

^include<stdio.h>

^defineNO0

#defineYES1

intmain(void)

longnum;/*valuetobechecked*/

longdiv;/*potentialdivisors*/

longlim;/*limittovalues*/

intprime;

printf(^Pleaseenterlimittovaluestobechecked;〃);

printf(/zEnterqtoquit.\n");

while(scanf&lim)=1&&lim>0)

(

for(num=2;num<=lim;num++)

(

for(div=2,prime=YES;(div*div)<=num;div++)

if(num%div==0)

prime=NO;/*numberisnotprime*/

if(prime==YES)

printf("%ldisprime.\n",num);

)

printf("Pleaseenteranotherlimit;〃);

printf("Enterqtoquit.\n");

)

return0;

)

PE7-11

/*pe7-ll.c*/

/*ProgrammingExercise7-11*/

#include<stdio.h>

^include<ctype.h>

intmain(void)

constdoubleprice_artichokes=1.25;

constdoubleprice_beets=0.65;

constdoubleprice_carrots=0.89;

constdoubleDISCOUNT.RATE=0.05;

charch;

doublelb_artichokes;

doublelb_beets;

doublelb_carrots;

doublelb_total;

doublecost_artichokes;

doublecost_beets;

doublecost_carrots;

doublecost_total;

doublefinal_total;

doublediscount;

doubleshipping;

printf("Enteratobuyartichokes,bforbeets,〃);

printf("cforcarrots,qtoquit:");

while((ch=getchar())!=’q'&&ch!二'Q')

(

if(ch=='\n)

continue;

while(getchar()!='\n')

continue;

ch=tolower(ch);

switch(ch)

(

case'a':printf("Enterpoundsofartichokes:");

scanf&lb_artichokes);

break;

case'b':printf("Enterpoundsofbeets:");

scanf&lb_beets);

break;

case'c':printf("Enterpoundsofcarrots:");

scanf&lb_carrots);

break;

default:printfC%cisnotavalidchoice.\nz/);

)

printf("Enteratobuyartichokes,bforbeets,");

printf(^cforcarrots,qtoquit:");

)

cost_artichokes=price_artichokes*lb_artichokes;

cost_beets=price_beets*lb_beets;

cost_carrots=price_carrots*lb_carrots;

cost_total=cost_artichokes+cost_beets+cost_carrots;

lb_total=lb_artichokes+lb_beets+lb_carrots;

if(lb_total<=0)

shipping=0.0;

elseif(lb_total<5.0)

shipping=3,50;

elseif(lb_total<20)

shipping=10.0;

else

shipping=8.0+0.1*lb_total;

if(cost_total>100.0)

discount=DISCOUNT_RATE*cost_total;

else

discount=0.0;

final_total=cost_total+shipping-discount;

printf(^Yourorder:\n");

printf(z,%.2flbsofartichokesat$%.2fperpound:$%.2f\n,z,

lb_artichokes,price_artichokes,cost_artichokes);

printf("%.2flbsofbeetsat$%.2fperpound:$%.2f\n”,

lb_beets,price_beets,cost_beets);

printf("%.2flbsofcarrotsat$%.2fperpound:$%.2f\n”,

lb_carrots,price_carrots,cost_carrots);

printf("Totalcostofvegetables:$%.2f\n",cost_total);

if(cost_total>100)

printf(^Volumediscount:$%.2f\n”,discount);

printf("Shipping:$%.2f\n",shipping);

printf("Totalcharges:$%.2f\n”,final_total);

return0;

)

Chapter8

PE8-1

/*ProgrammingExercise8-1*/

^include<stdio.h>

intmain(void)

(

intch;

intct=0;

while((ch=getchar())!=EOF)

ct++;

printf("%dcharactersread\n,/,ct);

return0;

)

PE8-3

/*ProgrammingExercise8-3*/

/*Usingctype.heliminatesneedtoassumeASCIIcoding*/

^include<stdio.h>

#include<ctype.h>

intmain(void)

(

intch;

intuct=0;

intlet=0;

while((ch=getchar())!=EOF)

if(isupper(ch))

uct++;

elseif(islower(ch))

lct++;

printf("%duppercasecharactersread\n,/,uct);

printf("%dlowercasecharactersread\n",let);

return0;

)

/*

oryoucoulduse

if(ch>='A'&&ch<='Z')

uct++;

elseif(ch>=,a&&ch<='z')

lct++;

*/

PE8-5

/*ProgrammingExercise8-5*/

/*binaryguess,c-animprovednumber-guesser*/

^include<stdio.h>

#include<ctype.h>

intmain(void)

(

inthigh=100;

intlow=1;

intguess二(high+low)/2;

charresponse;

printf(^Pickanintegerfrom1to100.Iwilltrytoguess");

printf(^it.\nRespondwithayifmyguessisright,with");

printf(^\nahifitishigh,andwithan1ifitislow.\n");

printf("Uh・・・isyournumber%d?\n〃,guess);

while((response=getchar())!='y')/*getresponse*/

(

if(response=='\n')

continue;

if(response!='h'&&response!=T')

(

printf("Idon'tunderstandthatresponse.Pleaseenterh

for\n");

printf(,zhigh,1forlow,oryforcorrect.\n^);

continue;

)

if(response=='h')

high=guess-1;

elseif(response=='1')

low=guess+1;

guess=(high+low)/2;

printf("Well,then,isit%d?\n”,guess);

)

printf("IknewIcoulddoit!\n〃);

return0;

PE8-7

/*ProgrammingExercise8-7*/

^include<stdio.h>

^include<ctype.h>

^defineBASEPAY18.75/*$8.75perhour*/

^defineBASEPAY29.33/*$9.33perhour*/

#defineBASEPAY310.00/*$10.00perhour*/

4defineBASEPAY411.20/*$11.20perhour*/

^defineBASEHRS40/*hoursatbasepay*/

^defineOVERTIME1.5/*1.5time*/

^defineAMT1300/*1stratetier*/

#defineAMT2150/*2stratetier*/

^defineRATE10.15/*ratefor1sttier*/

#defineRATE20.20/*ratefor2ndtier*/

^defineRATE30.25/*ratefor3rdtier*/

intgetfirst(void);

voidmenu(void);

intmain(void)

doublehours;

doublegross;

doublenet;

doubletaxes;

doublepay;

charresponse;

menu();

while((response=getfirst())!='q')

if(response=='\n,)/*skipovernewlines*/

continue;

response=tolower(response);/*acceptAasa,etc.*/

switch(response)

9,

casea:pay=BASEPAY1;break;

case'b,:pay=BASEPAY2;break;

,,

casec:pay=BASEPAY3;break;

case,d,:pay=BASEPAY4;break;

default:printf("Pleaseenterab,c,d,orq.\n");

menu();

continue;/*gotobeginningofloop*/

)

printf("Enterthenumberofhoursworkedthisweek:");

scanf(“机f”,&hours);

if(hours<=BASEHRS)

gross=hours*pay;

else

gross=BASEHRS*pay+(hours-BASEHRS)*pay*OVERTIME;

if(gross<=AMT1)

taxes=gross*RATE1;

elseif(gross<=AMT1+AMT2)

taxes=AMT1*RATE1+(gross-AMT1)*RATE2;

else

taxes=AMT1*RATE1+AMT2*RATE2+(gross-AMT1-AMT2)

*

RATE3;

net=gross-taxes;

printf(z,gross:$%.2f;taxes:$%.2f;net:$%・2f\n”,gross,taxes,

net);

menu();

)

printf("Done.\n");

return0;

)

voidmenu(void)

"*********\n");

printf("Enterthenumbercorrespondingtothedesiredpayrate”

“oraction:\n");

printfCa)$%4.2f/hrb)$%4.2f/hr\n〃,BASEPAY1,

BASEPAY2);

printffc)$%5.2f/hrd)$%5.2f/hr\n",BASEPAY3,

BASEPAY4);

printf(^q)quit'n");

"*********\n");

)

intgetfirst(void)

(

intch;

ch=getchar();

while(isspace(ch))

ch=getchar();

while(getchar()!='\n')

continue;

returnch;

)

Chapter9

PE9-1

/*ProgrammingExercise9-1*/

^include<stdio.h>

doublemin(doublea,doubleb);

intmain(void)

(

doublex,y;

printf("Entertwonumbers(qtoquit):");

while(scanf(z,%lf%lf",&x,&y)==2)

(

printf("Thesmallernumberis%f.\n”,min(x,y));

printf("Nexttwovalues(qtoquit):");

)

printf("Bye!\n");

return0;

)

doublemin(doublea,doubleb)

(

returna<b?a:b;

)

/*alternativeimplementation

doublemin(doublea,doubleb)

(

if(a<b)

returna;

else

returnb;

)

*/

PE9-3

/*ProgrammingExercise9-3*/

#include<stdio.h>

voidchLineRow(charch,intc,intr);

intmain(void)

charch;

intcol,row;

printf("Enteracharacter(#toquit):");

while((ch=getchar())!='#')

(

if(ch=='\n,)

continue;

printf("Enternumberofcolumnsandnumberofrows:");

if(scanf(“刎%d”,&col,&row)!=2)

break;

chLineRow(ch,col,row);

printf(,z\nEnternextcharacter(#toquit):");

)

printf("Bye!\n");

return0;

)

voidchLineRow(charch,intc,intr)

(

intcol,row;

for(row=0;row<r;row++)

(

for(col=0;col<c;col++)

putchar(ch);

putchar\n);

)

return;

)

PE9-5

/*ProgrammingExercise9-5*/

#include<stdio.h>

voidlarger_of(double*pl,double*p2);

intmain(void)

doublex,y;

printf("Entertwonumbers(qtoquit):〃);

while(scanf(,z%lf%lf”,&x,&y)==2)

(

larger_of(&x,&y);

printf(z,Themodifiedvaluesare%fand%f.\n〃,x,y);

printf("Nexttwovalues(qtoquit):");

)

printf("Bye!\n");

return0;

)

voidlarger_of(double*pl,double*p2)

(

doubletemp=*pl>*p2?*pl:*p2;

*pl=*p2=temp;

PE9-7

/*ProgrammingExercise9-7*/

ttinclude<stdio.h>

doublepower(doublea,intb);/*ANSIprototype*/

intmain(void)

{

doublex,xpow;

intn;

printf("Enteranumberandtheintegerpower");

printf("towhich\nthenumberwillberaised.Enterq");

printf("toquit.\n");

while(scanf&x,&n)==2)

(

xpow=power(x,n);/*functioncall*/

printf("%・3gtothepower%dis%・5g\n”,x,n,xpow);

printf("Enternextpairofnumbersorqtoquit.\n");

)

printf("Hopeyouenjoyedthispowertrip一bye!\nz,);

return0;

}

doublepower(doublea,intb)/*functiondefinition*/

doublepow=1;

inti;

if(b=0)

(

if(a=0)

printf(/z0tothe0undefined;using1asthevalue'n");

pow=1.0;

)

elseif(a==0)

pow=0.0;

elseif(b>0)

for(i=1;i<=b;i++)

pow*=a;

else/*b<0♦/

pow=1.0/power(a,-b);

returnpow;/*returnthevalueofpow*/

)

PE9-9

/*ProgrammingExercise9-9*/

^include<stdio.h>

voidto_base_n(intx,intbase);

intmain(void)

(

intnumber;

intb;

printf("Enteraninteger(qtoquit):\n^);

while(scanf("%d”,&number)==1)

(

printf("Enternumberbase(2-10):");

scanf("%d",&b);

printf("Base%dequivalent:",b);

to_base_n(number,b);

putchar('\n);

printf("Enteraninteger(qtoquit):\n/z);

}

return0;

)

voidto_base_n(intx,intbase)/*recursivefunction*/

intr;

r=x%base;

if(x>=2)

to_base_n(x/base,base);

putchar('O'+r);

return;

)

Chapter10

PE10-1

/*ProgrammingExercise10-1*/

ttinclude<stdio.h>

^defineMONTHS12/*numberofmonthsinayear*/

^defineYRS5/*numberofyearsofdata*/

intmain(void)

/*initializingrainfalldatafor1990-

constfloatrain[YRS][MONTHS]={

I2oI

{10.2,8.1,6.8,4.2,2.1,1.8,0.2,0.3,X•o6.X7.4)

①17工2

(9.2,9.8,4.4,3.3,2.2,0.8,0.4,0.0,6,•,4.

132

0,2.工

(6.6,5.5,3.8,2.8,1.6,0.2,0.0,0.0,os.2•,6u,5.

4,工4f6

{4.3,•,L4.

4.3,4.3,3.0,2.0,1.0,0.2,0.2,6.

o.

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论