2021-02-23

作业:
89.
不会
#include <stdio.h>
#define SIZE 10
void main()
{
int x[SIZE],i,n=0;
float sum=0;
printf(“Enter 10 integers:\n”);
for(i=0;i<SIZE;i++)
{
printf("%d:",i+1);
scanf("%d",&x[i]);
if(x[i]>0)
{
sum+=x[i];
n++;
}
}

printf(“the counter is %d\n”,n);
printf(“the average is %f\n”,sum/n);
}
90.
不会
#include <stdio.h>
#define SIZE 10
void main()
{
int x[SIZE],i,max,min;
printf(“Enter 10 integers:\n”);
for(i=0;i<SIZE;i++)
{
printf("%d:",i+1);
scanf("%d",&x[i]);
}
max=min=x[0];
for(i=1;i<SIZE;i++)
{ if(max<x[i]) max=x[i];
if(min>x[i]) min=x[i];
}
printf(“Maximum value is %d\n”,max);
printf(“Minimum value is %d\n”,min);
}
91.
不会
#include <stdio.h>
void main()
{
char string[81];
int i,num=0,word=0;
char c;
gets(string);
for(i=0;(c=string[i])!=’\0’;i++)
if(c==’ ')
word=0;
else if(word0)
{
word=1;
num++;
}
printf(“There are %d words in the line\n”,num);
}
92.
不会
#include <stdio.h>
void main()
{
int n;
for(n=7;n<1000;n++)
if(n%7
0&&n%65&&n%54&&n%43&&n%32&&n%21)
{
printf("%d\t",n);
break;
}
}
93.
#include"stdio.h"
void main()
{
int year,num=0;
for(year=1000;year<=2000;year++)
if(year%4
0&&year%100!=0||year%400==0)
{
num++;
printf("%d “,year);
}
printf(”\ntotal is %d\n",num);
}
94.
不会
#include"stdio.h"
void main()
{
long int total=1;
int n=1;
while(n<=10)
{
total*=n;
n++ ;
}
printf(“the result is %ld\n”,total);
}
95.
不会
#include"stdio.h"
main()
{
int day=0,buy=2;
float sum=0.0,ave;
do
{
sum+=0.8buy;
day++;
buy
=2;
}while(buy<=100);
ave=sum/day;
printf("%f\n",ave);
}
96.
不会
#include"stdio.h"
void main()
{
int x, y, end=1;
int i;
printf(“please input x and y:\n”);
scanf("%d%d",&x,&y);
for (i=1;i<=y;i++)
end=end*x%1000;
printf("%d",end);
}
97.
不会
#include <stdio.h>
main()
{
int a,b,c;
for (a=1; a<=3; a++)
for (b=1; b<=3; b++)
for (c=1; c<=3; c++)
if (a!=1&&c!=1&&c!=3&&a!=b&&a!=c&&b!=c)

{
    printf("%c will marry to a\n", 'x' + a - 1);
    printf("%c will marry to b\n", 'x' + b - 1);
    printf("%c will marry to c\n", 'x' + c - 1);
}

}
98.
不会
#include"stdio.h"
#include"math.h"
void main()
{
float a,b,c; //定义 a,b,c为三条边
float s,area;
printf(“请输入三角形的三条边:\n”);
scanf("%f%f%f",&a,&b,&c);
if (a+b>c&&b+c>a&&a+c>b)
{
s = (a+b+c)/2;
area = sqrt(s*(s-a)(s-b)(s-c));
printf(“面积是:%f\n”,area);
if (ab && ac)
printf(“等边三角形\n”);
else if (ab || ac || b==c)
printf(“等腰三角形\n”);
else if(aa + bb == cc || aa + cc == bb || bb + cc == a*a)
printf(“直角三角形\n”);
else
printf(“普通三角形\n”);
}
else
printf(“不能构成三角形\n”);
}

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值