91
#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);
}
92
#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);
}
93
#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(word==0)
{
word=1;
num++;
}
printf(“There are %d words in the line\n”,num);
}
94
#include <stdio.h>
void main()
{
int n;
for(n=7;n<1000;n++)
if(n%70&&n%65&&n%54&&n%43&&n%32&&n%21)
{
printf("%d\t",n);
break;
}
}
95
#include"stdio.h"
void main()
{
int year,num=0;
for(year=1000;year<=2000;year++)
if(year%40&&year%100!=0||year%4000)
{
num++;
printf("%d “,year);
}
printf(”\ntotal is %d\n",num);
}
96
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);
}
97
#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);
}
98
#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);
}
99
#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);
}
}
100
#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”);
}