- 202.50 KB
- 2022-04-22 11:18:29 发布
- 1、本文档共5页,可阅读全部内容。
- 2、本文档内容版权归属内容提供方,所产生的收益全部归内容提供方所有。如果您对本文有版权争议,可选择认领,认领后既往收益都归您。
- 3、本文档由用户上传,本站不保证质量和数量令人满意,可能有诸多瑕疵,付费之前,请仔细先通过免费阅读内容等途径辨别内容交易风险。如存在严重挂羊头卖狗肉之情形,可联系本站下载客服投诉处理。
- 文档侵权举报电话:19940600175。
'1-5#includeintmain(){printf("**************************nn");printf("VeryGood!nn");printf("**************************n");return0;}1-6#includeintmain(){inta,b,c,max;printf("pleaseinputa,b,c:n");scanf("%d,%d,%d",&a,&b,&c);max=a;if(max#includeintmain(){floatp,r,n;r=0.1;n=10;p=pow(1+r,n);printf("p=%fn",p);return0;}3-2-1#include#includeintmain(){floatr5,r3,r2,r1,r0,p,p1,p2,p3,p4,p5;p=1000;r5=0.0585;r3=0.054;r2=0.0468;r1=0.0414;r0=0.0072;p1=p*((1+r5)*5);//一次存5年期p2=p*(1+2*r2)*(1+3*r3);//先存2年期,到期后将本息再存3年期p3=p*(1+3*r3)*(1+2*r2);//先存3年期,到期后将本息再存2年期60
p4=p*pow(1+r1,5);//存1年期,到期后将本息存再存1年期,连续存5次p5=p*pow(1+r0/4,4*5);//存活期存款。活期利息每一季度结算一次printf("p1=%fn",p1);//输出按第1方案得到的本息和printf("p2=%fn",p2);//输出按第2方案得到的本息和printf("p3=%fn",p3);//输出按第3方案得到的本息和printf("p4=%fn",p4);//输出按第4方案得到的本息和printf("p5=%fn",p5);//输出按第5方案得到的本息和return0;}3-2-2#include#includeintmain(){doubler5,r3,r2,r1,r0,p,p1,p2,p3,p4,p5;p=1000;r5=0.0585;r3=0.054;r2=0.0468;r1=0.0414;r0=0.0072;p1=p*((1+r5)*5);//一次存5年期p2=p*(1+2*r2)*(1+3*r3);//先存2年期,到期后将本息再存3年期p3=p*(1+3*r3)*(1+2*r2);//先存3年期,到期后将本息再存2年期p4=p*pow(1+r1,5);//存1年期,到期后将本息存再存1年期,连续存5次p5=p*pow(1+r0/4,4*5);//存活期存款。活期利息每一季度结算一次printf("p1=%fn",p1);//输出按第1方案得到的本息和printf("p2=%fn",p2);//输出按第2方案得到的本息和printf("p3=%fn",p3);//输出按第3方案得到的本息和printf("p4=%fn",p4);//输出按第4方案得到的本息和printf("p5=%fn",p5);//输出按第5方案得到的本息和return0;}3-2-3#include#includeintmain(){floatr5,r3,r2,r1,r0,p,p1,p2,p3,p4,p5;p=1000;r5=0.0585;r3=0.054;r2=0.0468;r1=0.0414;r0=0.0072;60
p1=p*((1+r5)*5);//一次存5年期p2=p*(1+2*r2)*(1+3*r3);//先存2年期,到期后将本息再存3年期p3=p*(1+3*r3)*(1+2*r2);//先存3年期,到期后将本息再存2年期p4=p*pow(1+r1,5);//存1年期,到期后将本息存再存1年期,连续存5次p5=p*pow(1+r0/4,4*5);//存活期存款。活期利息每一季度结算一次printf("p1=%10.2fn",p1);//输出按第1方案得到的本息和printf("p2=%10.2fn",p2);//输出按第2方案得到的本息和printf("p3=%10.2fn",p3);//输出按第3方案得到的本息和printf("p4=%10.2fn",p4);//输出按第4方案得到的本息和printf("p5=%10.2fn",p5);//输出按第5方案得到的本息和return0;}3-3.#include#includeintmain(){floatd=300000,p=6000,r=0.01,m;m=log10(p/(p-d*r))/log10(1+r);printf("m=%6.2fn",m);return0;}3-4#includeintmain(){intc1,c2;c1=197;c2=198;printf("c1=%c,c2=%cn",c1,c2);printf("c1=%d,c2=%dn",c1,c2);return0;}3-5#includeintmain(){inta,b;floatx,y;charc1,c2;scanf("a=%db=%d",&a,&b);scanf("%f%e",&x,&y);scanf("%c%c",&c1,&c2);printf("a=%d,b=%d,x=%f,y=%f,c1=%c,c2=%cn",a,b,x,y,c1,c2);return0;}60
3-6#includeintmain(){charc1="C",c2="h",c3="i",c4="n",c5="a";c1=c1+4;c2=c2+4;c3=c3+4;c4=c4+4;c5=c5+4;printf("passworis%c%c%c%c%cn",c1,c2,c3,c4,c5);return0;}3-7#includeintmain(){floath,r,l,s,sq,vq,vz;floatpi=3.141526;printf("请输入圆半径r,圆柱高h∶");scanf("%f,%f",&r,&h);//要求输入圆半径r和圆柱高hl=2*pi*r;//计算圆周长ls=r*r*pi;//计算圆面积ssq=4*pi*r*r;//计算圆球表面积sqvq=3.0/4.0*pi*r*r*r;//计算圆球体积vqvz=pi*r*r*h;//计算圆柱体积vzprintf("圆周长为:l=%6.2fn",l);printf("圆面积为:s=%6.2fn",s);printf("圆球表面积为:sq=%6.2fn",sq);printf("圆球体积为:v=%6.2fn",vq);printf("圆柱体积为:vz=%6.2fn",vz);return0;}3-8-1#includeintmain(){intc1,c2;//整型定义printf("请输入两个整数c1,c2:");scanf("%d,%d",&c1,&c2);printf("按字符输出结果:n");printf("%c,%cn",c1,c2);printf("按ASCII码输出结果为:n");printf("%d,%dn",c1,c2);return0;}60
3-8-2#includeintmain(){charc1,c2;//定义字符型变量inti1,i2;//定义整型变量printf("请输入两个字符c1,c2:");scanf("%c,%c",&c1,&c2);i1=c1;//赋值给整型变量i2=c2;printf("按字符输出结果:n");printf("%c,%cn",i1,i2);printf("按整数输出结果:n");printf("%d,%dn",c1,c2);return0;}3-8-3#includeintmain(){charc1,c2;//定义为字符型inti1,i2;//定义为整型printf("请输入两个整数i1,i2:");scanf("%d,%d",&i1,&i2);c1=i1;//将整数赋值给字符变量c2=i2;printf("按字符输出结果:n");printf("%c,%cn",c1,c2);printf("按整数输出结果:n");printf("%d,%dn",c1,c2);return0;}3-8#includeintmain(){charc1,c2;printf("请输入两个字符c1,c2:");c1=getchar();c2=getchar();printf("用putchar语句输出结果为:");putchar(c1);putchar(c2);printf("n");60
printf("用printf语句输出结果为:");printf("%c%cn",c1,c2);return0;}4-4-1#includeintmain(){inta,b,c;printf("请输入三个整数:");scanf("%d,%d,%d",&a,&b,&c);if(aintmain(){inta,b,c,temp,max;printf("请输入三个整数:");scanf("%d,%d,%d",&a,&b,&c);temp=(a>b)?a:b;/*将a和b中的大者存入temp中*/max=(temp>c)?temp:c;/*将a和b中的大者与c比较,取最大者*/printf("三个整数的最大数是%dn",max);return0;}4-5#include#include#defineM1000intmain(){inti,k;printf("请输入一个小于%d的整数i:",M);scanf("%d",&i);if(i>M){printf("输入的数不符合要求,请重新输入一个小于%d的整数i:",M);60
scanf("%d",&i);}k=sqrt(i);printf("%d的平方根的整数部分是:%dn",i,k);return0;}4-6.#includeintmain(){intx,y;printf("输入x:");scanf("%d",&x);if(x<1)/*x<1*/{y=x;printf("x=%3d,y=x=%dn",x,y);}elseif(x<10)/*1==10*/{y=3*x-11;printf("x=%d,y=3*x-11=%dn",x,y);}return0;}4-8#includeintmain(){floatscore;chargrade;printf("请输入学生成绩:");scanf("%f",&score);while(score>100||score<0){printf("n输入有误,请重输");scanf("%f",&score);}switch((int)(score/10)){case10:case9:grade="A";break;case8:grade="B";break;case7:grade="C";break;case6:grade="D";break;case5:60
case4:case3:case2:case1:case0:grade="E";}printf("成绩是%5.1f,相应的等级是%cn",score,grade);return0;}4-10-1#includeintmain(){inti;doublebonus,bon1,bon2,bon4,bon6,bon10;bon1=100000*0.1;bon2=bon1+100000*0.075;bon4=bon2+100000*0.05;bon6=bon4+100000*0.03;bon10=bon6+400000*0.015;printf("请输入利润i:");scanf("%d",&i);if(i<=100000)bonus=i*0.1;elseif(i<=200000)bonus=bon1+(i-100000)*0.075;elseif(i<=400000)bonus=bon2+(i-200000)*0.05;elseif(i<=600000)bonus=bon4+(i-400000)*0.03;elseif(i<=1000000)bonus=bon6+(i-600000)*0.015;elsebonus=bon10+(i-1000000)*0.01;printf("奖金是:%10.2fn",bonus);return0;}4-10-2#includeintmain(){inti;doublebonus,bon1,bon2,bon4,bon6,bon10;intbranch;60
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("请输入利润i:");scanf("%d",&i);branch=i/100000;if(branch>10)branch=10;switch(branch){case0:bonus=i*0.1;break;case1:bonus=bon1+(i-100000)*0.075;break;case2:case3:bonus=bon2+(i-200000)*0.05;break;case4:case5:bonus=bon4+(i-400000)*0.03;break;case6:case7:case8:case9:bonus=bon6+(i-600000)*0.015;break;case10:bonus=bon10+(i-1000000)*0.01;}printf("奖金是%10.2fn",bonus);return0;}4-11#includeintmain(){intt,a,b,c,d;printf("请输入四个数:");scanf("%d,%d,%d,%d",&a,&b,&c,&d);printf("a=%d,b=%d,c=%d,d=%dn",a,b,c,d);if(a>b){t=a;a=b;b=t;}if(a>c){t=a;a=c;c=t;}if(a>d){t=a;a=d;d=t;}if(b>c){t=b;b=c;c=t;}if(b>d){t=b;b=d;d=t;}if(c>d){t=c;c=d;d=t;}60
printf("排序结果如下:n");printf("%d%d%d%dn",a,b,c,d);return0;}4-12#includeintmain(){inth=10;floatx1=2,y1=2,x2=-2,y2=2,x3=-2,y3=-2,x4=2,y4=-2,x,y,d1,d2,d3,d4;printf("请输入一个点(x,y):");scanf("%f,%f",&x,&y);d1=(x-x4)*(x-x4)+(y-y4)*(y-y4);/*求该点到各中心点距离*/d2=(x-x1)*(x-x1)+(y-y1)*(y-y1);d3=(x-x2)*(x-x2)+(y-y2)*(y-y2);d4=(x-x3)*(x-x3)+(y-y3)*(y-y3);if(d1>1&&d2>1&&d3>1&&d4>1)h=0;/*判断该点是否在塔外*/printf("该点高度为%dn",h);return0;}5-3#includeintmain(){intp,r,n,m,temp;printf("请输入两个正整数n,m:");scanf("%d,%d,",&n,&m);if(nintmain(){charc;intletters=0,space=0,digit=0,other=0;printf("请输入一行字符:n");while((c=getchar())!="n"){if(c>="a"&&c<="z"||c>="A"&&c<="Z")letters++;elseif(c=="")space++;elseif(c>="0"&&c<="9")digit++;elseother++;}printf("字母数:%dn空格数:%dn数字数:%dn其它字符数:%dn",letters,space,digit,other);return0;}5-5#includeintmain(){inta,n,i=1,sn=0,tn=0;printf("a,n=:");scanf("%d,%d",&a,&n);while(i<=n){tn=tn+a;/*赋值后的tn为i个a组成数的值*/sn=sn+tn;/*赋值后的sn为多项式前i项之和*/a=a*10;++i;}printf("a+aa+aaa+...=%dn",sn);return0;}5-6#includeintmain(){doubles=0,t=1;intn;for(n=1;n<=20;n++)60
{t=t*n;s=s+t;}printf("1!+2!+...+20!=%22.15en",s);return0;}5-7#includeintmain(){intn1=100,n2=50,n3=10;doublek,s1=0,s2=0,s3=0;for(k=1;k<=n1;k++)/*计算1到100的和*/{s1=s1+k;}for(k=1;k<=n2;k++)/*计算1到50各数的平方和*/{s2=s2+k*k;}for(k=1;k<=n3;k++)/*计算1到10的各倒数和*/{s3=s3+1/k;}printf("sum=%15.6fn",s1+s2+s3);return0;}5-8#includeintmain(){inti,j,k,n;printf("parcissusnumbersare");for(n=100;n<1000;n++){i=n/100;j=n/10-i*10;k=n%10;if(n==i*i*i+j*j*j+k*k*k)printf("%d",n);}printf("n");return0;}5-9#includeintmain(){intm,s,i;for(m=2;m<1000;m++)60
{s=0;for(i=1;iintmain(){inti,n=20;doublea=2,b=1,s=0,t;for(i=1;i<=n;i++){s=s+a/b;t=a,a=a+b,b=t;}printf("sum=%16.10fn",s);return0;}5-11#includeintmain(){doublesn=100,hn=sn/2;intn;for(n=2;n<=10;n++){sn=sn+2*hn;/*第n次落地时共经过的米数*/hn=hn/2;/*第n次反跳高度*/}printf("第10次落地时共经过%f米n",sn);printf("第10次反弹%f米n",hn);return0;}5-1260
#includeintmain(){intday,x1,x2;day=9;x2=1;while(day>0){x1=(x2+1)*2;/*第1天的桃子数是第2天桃子数加1后的2倍.*/x2=x1;day--;}printf("total=%dn",x1);return0;}5-13#include#includeintmain(){floata,x0,x1;printf("enterapositivenumber:");scanf("%f",&a);x0=a/2;x1=(x0+a/x0)/2;do{x0=x1;x1=(x0+a/x0)/2;}while(fabs(x0-x1)>=1e-5);printf("Thesquarerootof%5.2fis%8.5fn",a,x1);return0;}5-14#include#includeintmain(){doublex1,x0,f,f1;x1=1.5;do{x0=x1;f=((2*x0-4)*x0+3)*x0-6;f1=(6*x0-8)*x0+3;x1=x0-f/f1;}while(fabs(x1-x0)>=1e-5);printf("Therootofequationis%5.2fn",x1);60
return0;}5-15#include#includeintmain(){floatx0,x1,x2,fx0,fx1,fx2;do{printf("enterx1&x2:");scanf("%f,%f",&x1,&x2);fx1=x1*((2*x1-4)*x1+3)-6;fx2=x2*((2*x2-4)*x2+3)-6;}while(fx1*fx2>0);do{x0=(x1+x2)/2;fx0=x0*((2*x0-4)*x0+3)-6;if((fx0*fx1)<0){x2=x0;fx2=fx0;}else{x1=x0;fx1=fx0;}}while(fabs(fx0)>=1e-5);printf("x=%6.2fn",x0);return0;}5-16#includeintmain(){inti,j,k;for(i=0;i<=3;i++){for(j=0;j<=2-i;j++)printf("");for(k=0;k<=2*i;k++)printf("*");printf("n");}for(i=0;i<=2;i++){for(j=0;j<=i;j++)printf("");for(k=0;k<=4-2*i;k++)printf("*");60
printf("n");}return0;}5-17#includeintmain(){chari,j,k;/*是a的对手;j是b的对手;k是c的对手*/for(i="x";i<="z";i++)for(j="x";j<="z";j++)if(i!=j)for(k="x";k<="z";k++)if(i!=k&&j!=k)if(i!="x"&&k!="x"&&k!="z")printf("A--%cnB--%cnC--%cn",i,j,k);return0;}6-1#include#includeintmain(){inti,j,n,a[101];for(i=1;i<=100;i++)a[i]=i;a[1]=0;for(i=2;iintmain(){inti,j,min,temp,a[11];printf("enterdata:n");for(i=1;i<=10;i++){printf("a[%d]=",i);scanf("%d",&a[i]);}printf("n");printf("Theorginalnumbers:n");for(i=1;i<=10;i++)printf("%5d",a[i]);printf("n");for(i=1;i<=9;i++){min=i;for(j=i+1;j<=10;j++)if(a[min]>a[j])min=j;temp=a[i];a[i]=a[min];a[min]=temp;}printf("nThesortednumbers:n");for(i=1;i<=10;i++)printf("%5d",a[i]);printf("n");return0;}6-3#includeintmain(){inta[3][3],sum=0;inti,j;printf("enterdata:n");for(i=0;i<3;i++)for(j=0;j<3;j++)scanf("%3d",&a[i][j]);for(i=0;i<3;i++)sum=sum+a[i][i];printf("sum=%6dn",sum);return0;60
}6-4#includeintmain(){inta[11]={1,4,6,9,13,16,19,28,40,100};inttemp1,temp2,number,end,i,j;printf("arraya:n");for(i=0;i<10;i++)printf("%5d",a[i]);printf("n");printf("insertdata:");scanf("%d",&number);end=a[9];if(number>end)a[10]=number;else{for(i=0;i<10;i++){if(a[i]>number){temp1=a[i];a[i]=number;for(j=i+1;j<11;j++){temp2=a[j];a[j]=temp1;temp1=temp2;}break;}}}printf("Nowarraya:n");for(i=0;i<11;i++)printf("%5d",a[i]);printf("n");return0;}6-5#include#defineN5intmain(){inta[N],i,temp;printf("enterarraya:n");for(i=0;i#defineN10intmain(){inti,j,a[N][N];for(i=0;iintmain(){inta[15][15],i,j,k,p,n;p=1;while(p==1){printf("entern(n=1--15):");scanf("%d",&n);if((n!=0)&&(n<=15)&&(n%2!=0))p=0;}60
for(i=1;i<=n;i++)for(j=1;j<=n;j++)a[i][j]=0;j=n/2+1;a[1][j]=1;for(k=2;k<=n*n;k++){i=i-1;j=j+1;if((i<1)&&(j>n)){i=i+2;j=j-1;}else{if(i<1)i=n;if(j>n)j=1;}if(a[i][j]==0)a[i][j]=k;else{i=i+2;j=j-1;a[i][j]=k;}}for(i=1;i<=n;i++){for(j=1;j<=n;j++)printf("%5d",a[i][j]);printf("n");}return0;}6-8#include#defineN4#defineM5/*数组为4行5列*/intmain(){inti,j,k,a[N][M],max,maxj,flag;printf("pleaseinputmatrix:n");for(i=0;imax){max=a[i][j];/*将本行的最大数存放在max中*/maxj=j;/*将最大数所在的列号存放在maxj中*/}flag=1;/*先假设是鞍点,以flag为1代表*/for(k=0;ka[k][maxj])/*将最大数和其同列元素相比*/{flag=0;/*如果max不是同列最小,表示不是鞍点令flag1为0*/continue;}if(flag)/*如果flag1为1表示是鞍点*/{printf("a[%d][%d]=%dn",i,maxj,max);/*输出鞍点的值和所在行列号*/break;}}if(!flag)/*如果flag为0表示鞍点不存在*/printf("Itisnotexist!n");return0;}6-9#include#defineN15intmain(){inti,number,top,bott,mid,loca,a[N],flag=1,sign;charc;printf("enterdata:n");scanf("%d",&a[0]);i=1;while(i=a[i-1])i++;elseprintf("enterthisdataagain:n");}printf("n");for(i=0;ia[N-1]))//要查的数不在查找区间内loca=-1;//表示找不到while((!sign)&&(top<=bott)){mid=(bott+top)/2;if(number==a[mid]){loca=mid;printf("Hasfound%d,itspositionis%dn",number,loca+1);sign=1;}elseif(numberintmain(){inti,j,upp,low,dig,spa,oth;chartext[3][80];upp=low=dig=spa=oth=0;for(i=0;i<3;i++){printf("pleaseinputline%d:n",i+1);gets(text[i]);for(j=0;j<80&&text[i][j]!=" ";j++){if(text[i][j]>="A"&&text[i][j]<="Z")upp++;elseif(text[i][j]>="a"&&text[i][j]<="z")low++;elseif(text[i][j]>="0"&&text[i][j]<="9")dig++;elseif(text[i][j]=="")spa++;else60
oth++;}}printf("nuppercase:%dn",upp);printf("lowercase:%dn",low);printf("digit:%dn",dig);printf("space:%dn",spa);printf("other:%dn",oth);return0;}6-11#includeintmain(){chara[5]={"*","*","*","*","*"};inti,j,k;charspace="";for(i=0;i<5;i++){printf("n");printf("");for(j=1;j<=i;j++)printf("%c",space);for(k=0;k<5;k++)printf("%c",a[k]);}printf("n");return0;}6-12a-c#includeintmain(){intj,n;charch[80],tran[80];printf("inputciphercode:");gets(ch);printf("nciphercode:%s",ch);j=0;while(ch[j]!=" "){if((ch[j]>="A")&&(ch[j]<="Z"))tran[j]=155-ch[j];elseif((ch[j]>="a")&&(ch[j]<="z"))tran[j]=219-ch[j];elsetran[j]=ch[j];j++;60
}n=j;printf("noriginaltext:");for(j=0;jintmain(){intj,n;charch[80];printf("inputciphercode:n");gets(ch);printf("nciphercode:%sn",ch);j=0;while(ch[j]!=" "){if((ch[j]>="A")&&(ch[j]<="Z"))ch[j]=155-ch[j];elseif((ch[j]>="a")&&(ch[j]<="z"))ch[j]=219-ch[j];elsech[j]=ch[j];j++;}n=j;printf("originaltext:");for(j=0;jintmain(){chars1[80],s2[40];inti=0,j=0;printf("inputstring1:");scanf("%s",s1);printf("inputstring2:");scanf("%s",s2);while(s1[i]!=" ")i++;60
while(s2[j]!=" ")s1[i++]=s2[j++];s1[i]=" ";printf("nThenewstringis:%sn",s1);return0;}6-14#includeintmain(){inti,resu;chars1[100],s2[100];printf("inputstring1:");gets(s1);printf("ninputstring2:");gets(s2);i=0;while((s1[i]==s2[i])&&(s1[i]!=" "))i++;if(s1[i]==" "&&s2[i]==" ")resu=0;elseresu=s1[i]-s2[i];printf("nresult:%d.n",resu);return0;}6-15#include#includeintmain(){chars1[80],s2[80];inti;printf("inputs2:");scanf("%s",s2);for(i=0;i<=strlen(s2);i++)s1[i]=s2[i];printf("s1:%sn",s1);return0;}7-1-1#includeintmain(){inthcf(int,int);intlcd(int,int,int);intu,v,h,l;scanf("%d,%d",&u,&v);60
h=hcf(u,v);printf("H.C.F=%dn",h);l=lcd(u,v,h);printf("L.C.D=%dn",l);return0;}inthcf(intu,intv){intt,r;if(v>u){t=u;u=v;v=t;}while((r=u%v)!=0){u=v;v=r;}return(v);}intlcd(intu,intv,inth){return(u*v/h);}7-1-2#includeintHcf,Lcd;intmain(){voidhcf(int,int);voidlcd(int,int);intu,v;scanf("%d,%d",&u,&v);hcf(u,v);lcd(u,v);printf("H.C.F=%dn",Hcf);printf("L.C.D=%dn",Lcd);return0;}voidhcf(intu,intv){intt,r;if(v>u){t=u;u=v;v=t;}while((r=u%v)!=0){u=v;v=r;}60
Hcf=v;}voidlcd(intu,intv){Lcd=u*v/Hcf;}7-2#include#includefloatx1,x2,disc,p,q;intmain(){voidgreater_than_zero(float,float);voidequal_to_zero(float,float);voidsmaller_than_zero(float,float);floata,b,c;printf("inputa,b,c:");scanf("%f,%f,%f",&a,&b,&c);printf("equation:%5.2f*x*x+%5.2f*x+%5.2f=0n",a,b,c);disc=b*b-4*a*c;printf("root:n");if(disc>0){greater_than_zero(a,b);printf("x1=%fttx2=%fn",x1,x2);}elseif(disc==0){equal_to_zero(a,b);printf("x1=%fttx2=%fn",x1,x2);}else{smaller_than_zero(a,b);printf("x1=%f+%fitx2=%f-%fin",p,q,p,q);}return0;}voidgreater_than_zero(floata,floatb){x1=(-b+sqrt(disc))/(2*a);x2=(-b-sqrt(disc))/(2*a);}voidequal_to_zero(floata,floatb){60
x1=x2=(-b)/(2*a);}voidsmaller_than_zero(floata,floatb){p=-b/(2*a);q=sqrt(-disc)/(2*a);}7-3#includeintmain(){intprime(int);intn;printf("inputaninteger:");scanf("%d",&n);if(prime(n))printf("%disaprime.n",n);elseprintf("%disnotaprime.n",n);return0;}intprime(intn){intflag=1,i;for(i=2;i#defineN3intarray[N][N];intmain(){voidconvert(intarray[][3]);inti,j;printf("inputarray:n");for(i=0;i#includeintmain(){voidinverse(charstr[]);charstr[100];printf("inputstring:");scanf("%s",str);inverse(str);printf("inversestring:%sn",str);return0;}voidinverse(charstr[]){chart;inti,j;for(i=0,j=strlen(str);i<(strlen(str)/2);i++,j--){t=str[i];str[i]=str[j-1];str[j-1]=t;}}60
7-6#includeintmain(){voidconcatenate(charstring1[],charstring2[],charstring[]);chars1[100],s2[100],s[100];printf("inputstring1:");scanf("%s",s1);printf("inputstring2:");scanf("%s",s2);concatenate(s1,s2,s);printf("nThenewstringis%sn",s);return0;}voidconcatenate(charstring1[],charstring2[],charstring[]){inti,j;for(i=0;string1[i]!=" ";i++)string[i]=string1[i];for(j=0;string2[j]!=" ";j++)string[i+j]=string2[j];string[i+j]=" ";}7-7#includeintmain(){voidcpy(char[],char[]);charstr[80],c[80];printf("inputstring:");gets(str);cpy(str,c);printf("Thevowellettersare:%sn",c);return0;}voidcpy(chars[],charc[]){inti,j;for(i=0,j=0;s[i]!=" ";i++)if(s[i]=="a"||s[i]=="A"||s[i]=="e"||s[i]=="E"||s[i]=="i"||s[i]=="I"||s[i]=="o"||s[i]=="O"||s[i]=="u"||s[i]=="U"){c[j]=s[i];j++;}c[j]=" ";60
}7-8#include#includeintmain(){charstr[80];voidinsert(char[]);printf("inputfourdigits:");scanf("%s",str);insert(str);return0;}voidinsert(charstr[]){inti;for(i=strlen(str);i>0;i--){str[2*i]=str[i];str[2*i-1]="";}printf("output:n%sn",str);}7-9#includeintletter,digit,space,others;intmain(){voidcount(char[]);chartext[80];printf("inputstring:n");gets(text);printf("string:");puts(text);letter=0;digit=0;space=0;others=0;count(text);printf("nletter:%dndigit:%dnspace:%dnothers:%dn",letter,digit,space,others);return0;}voidcount(charstr[]){inti;for(i=0;str[i]!=" ";i++)if((str[i]>="a"&&str[i]<="z")||(str[i]>="A"&&str[i]<="Z"))60
letter++;elseif(str[i]>="0"&&str[i]<="9")digit++;elseif(str[i]==32)space++;elseothers++;}7-10#include#includeintmain(){intalphabetic(char);intlongest(char[]);inti;charline[100];printf("inputoneline:n");gets(line);printf("Thelongestwordis:");for(i=longest(line);alphabetic(line[i]);i++)printf("%c",line[i]);printf("n");return0;}intalphabetic(charc){if((c>="a"&&c<="z")||(c>="A"&&c<="z"))return(1);elsereturn(0);}intlongest(charstring[]){intlen=0,i,length=0,flag=1,place=0,point;for(i=0;i<=strlen(string);i++)if(alphabetic(string[i]))if(flag){point=i;flag=0;}elselen++;else{flag=1;60
if(len>=length){length=len;place=point;len=0;}}return(place);}7-11#include#include#defineN10charstr[N];intmain(){voidsort(char[]);inti,flag;for(flag=1;flag==1;){printf("inputstring:n");scanf("%s",&str);if(strlen(str)>N)printf("stringtoolong,inputagain!");elseflag=0;}sort(str);printf("stringsorted:n");for(i=0;i