求c语言大神解答!!在线等!!急!!!谢谢了!!!
展开全部
#include <stdio.h>
int main()
{
int a[100];
int even=0, n=0,i;
float ave = 0;
FILE *fp;
fp = fopen("tx.txt", "r");
if(fp == NULL) return -1;
while(1)
{
if(fscanf(fp,&a[n]) != 1) break;
if(a[n]%2==0)
{
even++;
ave+=a[n];
}
n++;
}
printf("偶数平均值为%f\n",ave/even);
for(i = 0; i < n; i ++)
{
int t,r=0;
t = a[i];
while(t)
{
r+=t%10;
t/=10;
}
if(r > 10)printf("%d ",a[i]);
}
fclose(fp);
return 0;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询