二5555

1 篇文章 0 订阅
blank
#include <stdlib.h>
#include <stdio.h>
#define N 10
double fun(double x)
{ int i, j; double av, y[N];
av=0;
for(i=0; i<N; i++)
/found/
av+=x[i]/N;
for(i=j=0; i<N; i++)
if( x[i]<av ){
y[j]=x[i]; x[i]=-1;
/found/
j++;
}
i=0;
while(i<N)
{ if( x[i]!= -1 ) y[j++]=x[i];
/found/
i++;
}
for(i=0; i<N; i++)x[i] = y[i];
return av;
}
void main()
{ int i; double x[N];
for(i=0; i<N; i++){ x[i]=rand()%50; printf("%4.0f,x[i]);}
printf(”\n");
printf("\nThe average is: %f\n",fun(x));
printf("\nThe result :\n",fun(x));
for(i=0; i<N; i++) printf("%5.0f,x[i]);
printf(”\n");
}
modi
#include <stdlib.h>
#include <stdio.h>
#define N 10
double fun(double x)
{ int i, j; double av, y[N];
av=0;
for(i=0; i<N; i++)
/found/
av+=x[i]/N;
for(i=j=0; i<N; i++)
if( x[i]<av ){
y[j]=x[i]; x[i]=-1;
/found/
j++;
}
i=0;
while(i<N)
{ if( x[i]!= -1 ) y[j++]=x[i];
/found/
i++;
}
for(i=0; i<N; i++)x[i] = y[i];
return av;
}
void main()
{ int i; double x[N];
for(i=0; i<N; i++){ x[i]=rand()%50; printf("%4.0f,x[i]);}
printf(”\n");
printf("\nThe average is: %f\n",fun(x));
printf("\nThe result :\n",fun(x));
for(i=0; i<N; i++) printf("%5.0f,x[i]);
printf(”\n");
}
prog
#include<conio.h>
#include<stdio.h>
#include<stdlib.h>
#define M 4
#define N 5
int fun( int a [M][N])
{
int i,j,sum=0;
for(i=0;i<M;i++)
for(j=0;j<N;j++)
if(i0||iM-1||j0||jN-1)
sum=sum+a[i][j];
return sum;
}
void main()
{
FILE wf;
int aa[M][N]={{1,3,5,7,9},{2,9,9,9,4},{6,9,9,9,8},{1,3,5,7,0}};
int i, j, y;
system(“CLS”);
printf ("The original data is :\n “);
for(i=0; i<M;i++)
{for (j=0; j<N;j++)
printf(%6d “,aa[i][j]);
printf(”\n “);
}
y=fun(aa);
printf(”\nThe sun: %d\n “,y);
printf(”\n ");
//
wf=fopen(“out.dat”,“w”);
fprintf (wf,"%d",y);
fclose(wf);
/**/
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值