C语言程序设计苏小红版答案

合集下载
相关主题
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
main()
{
float a,b,c,s,area;
printf("Inputa,b,c:");
scanf("%f,%f,%f",&a,&b,&c);
if(a+b>c&&a+c>b&&b+c>a)
{
s=(a+b+c)/2;
area=(float)sqrt(s*(s-a)*(s-b)*(s-c));
printf("area=%f\n",area);
{
printf("x=%d\n",x);
find=1;
x++;
}
}
}
/*int x,find=0;
for (x=1;!find;x++)
{
if(x%2==1&&x%3==2&&x%5==4&&x%6==5&&x%7==0)
{
printf("x=%d\n",x);
find=1;
}
}
}*/
#include<>
main()
{
int n=1,count=1;
float x;
double sum,term;
printf("Input x:");
scanf("%f",&x);
sum=x;
term=x;
do{
term=-term*x*x/((n+1)*(n+2));
sum=sum+term;
n=n+2;
count++;
{
printf("ch是其他字符\n");
}
}
#include<>
main()
{
int score,grade;
printf("Input score:");
scanf("%d",&score);
grade=score/10;
if(score<0||score>100)
{
printf("Input error\n");
}
}
#include<>
main()
{
char ch;
printf("Inputch:");
scanf("%c",&ch);
if(ch>='a'&&ch<='z')
{
ch=getchar();
ch=ch-32;
printf("%c,%d\n",ch,ch);
}
else if(ch>='A'&&ch<='Z')
{
printf("*");
}
printf("\n");
}
}
(2) #include<>
main()
{
int k=4,n;
for(n=0;n<k;n++)
{
if(n%2==0) continue;
k--;
}
printf("k=%d\n,n=%d\n",k,n);
}
(3) #include<>
main()
}while(fabs(term)>=1e-5);
printf("sin(x)=%f,count=%d\n",sum,count);
}
#include<>
main()
{
int x=1,find=0;
while(!find)
{
if(x%2==1&&x%3==2&&x%5==4&&x%6==5&&x%7==0)
printf("31天\n");
break;
case 11:
case 9:
case 6:
case 4:
printf("30天\n");
break;
case 2:
if(year%4==0&&year!=0||year%400==0)
{
printf("29天\n");
}
else
{
printf("28天\n");
{Baidu Nhomakorabea
int k=4,n;
for(n=0;n<k;n++)
{
if(n%2==0) break;
k--;
}
printf("k=%d,n=%d\n",k,n);
}
(1) #include<>
main()
{
int i,sum=0;
for(i=1;i<=101;i++)
{
sum=sum+i;
}
printf("sum=%d\n",sum);
printf("x=%f,y=%f\n",x,y);
}
(1) #include<>
main()
{
char c1='a',c2='b',c3='c';
printf("a%cb%cc%c\n",c1,c2,c3);
}
(2) #include<>
main()
{
int a=12,b=15;
printf("a=%d%%,b=%d%%\n",a,b);
}
#include<>
#include<>
main()
{
float a,b,c;
double x,y;
printf("Inputa,b,c:");
scanf("%f,%f,%f",&a,&b,&c);
x=(-b+sqrt(b*b-4*a*c))/(2*a);
y=(-b-sqrt(b*b-4*a*c))/(2*a);
if(b*b-4*a*c>0)
{
x=(-b+sqrt(b*b-4*a*c))/(2*a);
y=(-b-sqrt(b*b-4*a*c))/(2*a);
printf("x=%f,y=%f\n",x,y);
}
else if(b*b-4*a*c==0)
{
x=-b/(2*a);
y=-b/(2*a);
printf("x=%f,y=%f\n",x,y);
}
else
{
printf("该方程无实根\n");
}
}
#include<>
main()
{
int year,flag;
printf("Input a year:");
scanf("%d",&year);
if(year%4==0&&year%400!=0||year%400==0)
{
flag=1;
}
else
printf("a=%d,b=%d\n",a,b);
printf("x=%f,b=%f\n",x,y);
}
#include<>
main()
{
float a;
printf("Innputa:");
scanf("%f",&a);
if(a>=0)
{
a=a;
printf("a=%f\n",a);
}
else
{
scanf("%d,%d",&year,&month);
if(month>12||month<=0)
{
printf("error month\n");
}
else
{
switch(year,month)
{
case 12:
case 10:
case 8:
case 7:
case 5:
case 3:
case 1:
}
#include<>
#include<>
main()
{
float rate=;
float n,capital,deposit;
printf("Input n,capital:");
scanf("%f,%f",&n,&capital);
deposit=capital*pow(1+rate,n);
printf("deposit=%f\n",deposit);
printf("ch是数字字符\n");
}
else if(ch>=65&&ch<=90)
{
printf("ch是大写字母\n");
}
else if(ch>=97&&ch<=122)
{
printf("ch是小写字母\n");
}
else if(ch==32)
{
printf("ch是空格\n");
}
else
main()
{
int i,n;
long p=1,m=1;
printf("Input n:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
p=i*i;
m=i*i*i;
printf("p=%d,m=%d\n",i,p,i,m);
}
}
#include<>
main()
{
float c,f;
C语言程序设计苏小红版答案
#include<>
main()
{
float x=,y=,z=;
printf("x=%f\n",x);
printf("y=%f\n",y);
printf("z=%f\n",z);
}
(1) #include<>
main()
{
int a=12,b=3;
float x=,y=;
printf("%d\n",(float)(a*b)/2);
{
int n=1;
float term=,sign=1,sum=0;
while(term<=-1e-4||term>=1e-4)
{
term=sign;
sum=sum+term;
sign=sign+n;
n++;
}
printf("sum=%f\n",sum);
}
(5) #include<>
#include<>
for(c=-40;c<=110;c=c+10)
{
f=9/5*c+32;
printf("f=%f\n",f);
}
}
#include<>
}
(2) #include<>
main()
{
long i;
long term,sum=0;
for(i=1;i<=101;i=i+2)
{
term=i*(i+1)*(i+2);
sum=sum+term;
}
printf("sum=%ld\n",sum);
}
(4) #include<>
#include<>
main()
a=-a;
printf("a=%f\n",a);
}
}
#include<>
main()
{
int a;
printf("Inputa:");
scanf("%d",&a);
if(a%2==0)
{
printf("a是偶数");
}
else
{
printf("a是奇数");
}
}
#include<>
#include<>
{
ch=getchar();
ch=ch+32;
printf("%c,%d\n",ch,ch);
}
else
{
printf("%c",ch);
}
}
#include<>
main()
{
char ch;
printf("Inputch:");
scanf("%c",&ch);
if(ch>=48&&ch<=57)
{
}
break;
default:
printf("Input error\n");
}
}
}
(1) #include<>
main()
{
int i,j,k;
char space=' ';
for(i=1;i<=4;i++)
{
for(j=1;j<=i;j++)
{
printf("%c",space);
}
for(k=1;k<=6;k++)
}
else if(score>=60&&score<70)
{
printf("%d--D\n",score);
}
else if(score>=0&&score<60)
{
printf("%d- -E\n",score);
}
}
#include<>
main()
{
int year,month;
printf("Input year,month:");
}
if(score>=90&&score<=100)
{
printf("%d--A\n",score);
}
else if(score>=80&&score<90)
{
printf("%d--B\n",score);
}
else if(score>=70&&score<80)
{
printf("%d--C\n",score);
printf("%d\n",(int)x%(int)y);
}
#include<>
main()
{
int x,b0,b1,b2,s;
printf("Inputx:");
scanf("%d",&x);
b2=x/100;
b1=(x-b2*100)/10;
b0=x%10;
s=b0*100+b1*10+b2;
printf("s=%d\n",s);
}
(3) #include<>
main()
{
int a,b;
scanf("%2d%*2s%2d",&a,&b);
printf("%d,%d\n",a,b);
}
#include<>
main()
{
long a,b;
float x,y;
scanf("%d,%d\n",&a,&b);
scanf("%f,%f\n",&x,&y);
{
flag=0;
}
if(flag==1)
{
printf("%d is a leap year !\n",year);
}
else
{
printf("%d is not a leap year !\n",year);
}
}
#include<>
main()
{
int year,flag;
printf("Input a year:");
scanf("%d",&year);
flag=year%400==0||year%4==0&&year%100!=01:0;
if(flag==1&&flag!=0)
{
printf("%d is a leap year !\n",year);
}
else
{
printf("%d is not a leap year !\n",year);
}
else
{
printf("不是三角形");
}
}
#include<>
#include<>
main()
{
float a,b,c,x,y;
printf("Inputa,b,c:");
scanf("%f,%f,%f",&a,&b,&c);
if(a==0)
{
printf("该方程不是一元二次方程\n");
}
相关文档
最新文档