c语言答案速查,c语言答案

main()

{ int i,resu;

char s1[100],s2[100];

printf("\n input string1:");

gets(s1);

printf("\n Input string2:");

gets(s2);

i=0;

while(s1[i]==s2[i]&&s1[i]!='\0') i++;

if(s1[i]=='\0'&&s2[i]=='0') resu=0;

else resu=s1[i]-s2[i];

printf("\n result:%d\n",resu);

}

15.

#include "stdio.h"

main()

{

char s1[80],s2[80];

int i;

printf("Input s2:");

scanf("%s",s2);

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

{

if(m%i==0&&n%i==0) {t=i; break;}

}

return(t);

}

int minbeishu(int m,int n)

{

int i,t,k;

if(m>=n) k=m;

else k=n;

i=k;

while(1)

{

if(i%m==0&&i%n==0) {t=i;break;}

i++;

}

return t;

}

main()

{int a,b,max,min;

printf("enter two number is: ");

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

max=maxyueshu(a,b);

min=minbeishu(a,b);

printf("max=%d,min=%d\n",max,min);

}

解法二:

#include "stdio.h"

int maxyueshu(int m,int n)

{

int t,r;

if(m>n) {t=m;m=n;n=t;}

r=n%m;

while(r!=0)

{

n=m;m=r;r=n%m;

}

return m;

}

int minbeishu(int m,int n)

{

int t,k;

k=maxyueshu(m,n);

t=m*n/k;

return t;

}

main()

{

int a,b,max,min;

printf("enter two number is: ");

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

max=maxyueshu(a,b);

min=minbeishu(a,b);

printf("max=%d,min=%d\n",max,min);

}

2.

#include"stdio.h"

#include"math.h"

float shigen(float a,float b,float q)

{

float x1,x2;

x1=(-b+sqrt(q))/(2*a);

x2=(-b-sqrt(q))/(2*a);

printf("two shigen is x1=%.3f and x2=%.3f\n",x1,x2);

}

float denggen(float a,float b)

{

float x;

x=-b/(2*a);

printf("denggen is x=%.3f\n",x);

}

float xugen(float a,float b,float q)

{

float x,y;

x=-b/(2*a);

y=sqrt(-q)/(2*a);

printf("two xugen is x1=%.3f+%.3fi and x2=%.3f-%.3fi\n",x,y,x,y);

}

main()

{

float a,b,c,q;

printf("input a b c is: ");

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

printf("\n");

q=b*b-4*a*c;

if(q>0) shigen(a,b,q);

else if(q==0) denggen(a,b);

else xugen(a,b,q);

}

3.

#include"stdio.h"

int sushu(int m)

{

int i,t;

for(i=2;i=65&&str[i]<=90||str[i]>=97&&str[i]<=122) b[0]++;

else if(str[i]>=48&&str[i]<=57) b[1]++;

else if(str[i]==32) b[2]++;

else b[3]++;

}

}

main()

{

char str[100];

int i,a[4];

gets(str);

tongji(str,a);

printf("zimu Shuzi Kongge Qita numbers are:\n");

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

printf("%d ",a[i]);

printf("\n");

}

10.

#include"stdio.h"

cechang(char str[],char longword[])

{

int i=0,j=0,t=0;

static char word[15];

for(;str[i]!='\0';i++)

{

if(!(str[i]>=97&&str[i]<=122||str[i]>=65&&str[i]<=90))

{t=j;j=0;continue;}

word[j]=str[i];j++;

if(j>=t) strcpy(longword,word);}

}

main()

{char str[100],longword[15];

gets(str);

cechang(str,longword);

puts(longword);

}

11.

#include"stdio.h"

paixu(int x[])

{

int i,j,t;

for(j=0;j<9;j++)

for(i=0;i<9-j;i++)

if(x[i]>x[i+1]) {t=x[i+1];x[i+1]=x[i];x[i]=t;}

}

main()

{

int y[10];int i;

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

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

paixu(y);

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

printf("%d ",y[i]);

printf("\n");

}

12.

#include"stdio.h"

double shigen(int a,int b,int c,int d)

{

double x,y;x=1;

do{

y=a*x*x*x+b*x*x+c*x+d;

x=x-y/(3*a*x*x+2*b*x+c);

} while(y!=0);

return x;

}

main()

{

int a,b,c,d;double x;

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

x=shigen(a,b,c,d);

printf("x=%.3f\n",x);

}

13.#include"stdio.h"

float p(float x,int n)

{

float y;

if(n==0||n==1)

if(n==1) y=x;

else y=1;

else y=((2*n-1)*x-p(x,n-1)-(n-1)*p(x,n-2))/n;

return(y);

}

main()

{

float x,y;int n;

scanf("%f,%d",&x,&n);

y=p(x,n);

printf("y=%.3f\n",y);

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值