第2个回答 2015-03-23
第一题的答案
#include <stdio.h>
#define n 11
int main(int argc, const char * argv[])
{
int m[n];
int k,temp ;
for (int i=1; i<=10; i++) {
printf("请输出第%d个数:",i);
scanf("%d",&k);
m[i]= k;
//printf("%d",m[i]);
}
temp = m[1];
for (int j = 1; j<=10; j++) {
if (temp>m[j]) {
temp =m[j];
}
}
printf("%d",temp);
FILE *f;
f = fopen("/Users/tarena0/Desktop/min.txt", "w"); //路径自己可以改
fprintf(f, "%d",temp);
fclose(f);
return 0;
}
第二题主要部分
/* int num=0;
int n[k];
printf("请输入你要输入的数的个数:");
for (int i =1; i<=k ; i++) {
printf("请输入第%d个数字:\n",i );
scanf("%d",&n[i]);
if (n[i]%2!=0) {
num = num+n[i];
}
}
FILE *p;
p = fopen("/Users/tarena0/Desktop/number.txt","w");
fprintf(p,"%d",num);
fclose(p);
// printf("%d\n",num);*/
第三题:
#include <stdio.h>
#define k 100
int main(int argc, const char * argv[])
{
int num =0;
int averger;
int m[k];
for (int i=1; i<=k; i++) {
printf("请输入第%d个人得英语成绩:\n",i);
scanf("%d",&m[i]);
num =num +m[i];
}
averger = num/k;
int count=0;
for (int j=1; j<=k; j++) {
if (m[j]<averger) {
count++;
}
}
FILE *p;
p = fopen("/Users/tarena0/Desktop/w.txt","w");
fprintf(p, "%d",count);
fclose(p);
return 0;
}
第四题
#include <stdio.h>
#define k 100
int main(int argc, const char * argv[])
{
////// int k;
// K =random()*10;
int n;
int count=0;
int m[k];
printf("请输入一个数n:\n");
scanf("%d",&n);
printf("请输入一个长度为%d的一维数组\n",k);
for (int j=1; j<=k; j++) {
printf("请输入第%d个数字:\n",j);
scanf("%d",&m[j]);
if (m[j]<n) {
count++;
}
}
FILE *p;
p = fopen("/Users/tarena0/Desktop/tt.txt", "w");
fprintf(p, "%d",count);
fclose(p);
}
// insert code here...
//printf("Hello, World!\n");
// return 0;