满意答案
6kidf3xhs
2017.11.07
采纳率:41% 等级:8
已帮助:62人
2 个关键:
2位数字的随机数: a[i]= 10 + rand() % 90;
10位或个位 含5 的 并高于平均值的 数:
if (a[i]>ave && ( a[i]%5==0 || (a[i]/10) %5 == 0)) {b[n]=a[i];n++;}
程序:
#include
#include
int main()
{
int a[50],b[50];
int i,j,n,t;
float ave=0;
srand((unsigned)time(NULL));
for (i=0;i<50;i++){
a[i]= 10 + rand() % 90;
ave = ave + a[i];
}
ave = ave / 50.0;
for (i=0;i<50;i++) printf("%d ",a[i]);
printf("\nave=%g\n",ave);
n=0;
for (i=0;i<50;i++){
if (a[i]>ave && ( a[i]%5==0 || (a[i]/10) %5 == 0)) {b[n]=a[i];n++;}
}
for (i=0;i
if (b[j]>b[i]) {t=b[i];b[i]=b[j];b[j]=t;};
for (i=0;i
return 0;
}
00分享举报