学历课程
实验目的:
实验要求:
实验内容: #include<stdio.h>
#define N 10
#define M 4
void main() {
int a[N]={76,83,54,62,40,75,90,92,77,84};
int b[M]={60,76,90,101};
int c[M]={0};
int i,j;
for(i=0; i<N; i++) {
j=0;
while(a[i]>=b[j]) j++;
c[j]++;
}
for(i=0; i<M; i++) printf("%d ",c[i]);
printf("\n");
}
请输入运行结果:
#include<stdio.h>
#include<string.h>
void main() {
char a[5][10]={"student","worker","soldier","peasant","cadre"};
char s1[10], s2[10];
int i;
strcpy(s1,a[0]); strcpy(s2,a[0]);
for(i=1; i<5; i++) {
if(strcmp(a[i], s1)>0) strcpy(s1,a[i]);
if(strcmp(a[i], s2)<0) strcpy(s2,a[i]);
}
printf("%s %s\n",s1,s2);
}
请输入运行结果:
有一个数列,它的第一项为0,第二项为1,以后每一项都是它的前两项之和,试产生出此数列的前20项,并按逆序显示出来。
请输入运行结果:
从键盘上输入一行字符串,假定该字符串的长度不超过50,试统计出该串中每一种十进制数字字符的个数并输出。
请输入运行结果: