十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
#include stdio.h
网站建设哪家好,找成都创新互联!专注于网页设计、网站建设、微信开发、小程序设计、集团企业网站建设等服务项目。为回馈新老客户创新互联还提供了柳河免费建站欢迎大家使用!
#define N 40
void input(float *score, int size)
{
int i;
printf("Enter %d scores:\n", size);
for(i = 0; i size; i++)
scanf("%f", score[i]);
}
void output(float *score, int size)
{
int i;
printf("Scores:\n");
for(i = 0; i size; i++)
printf("%.2f ", score[i]);
}
float average(float *score, int size)
{
int i;
float ave = 0.0;
for(i = 0; i size; i++)
ave += score[i];
return ave/size;
}
int main(void)
{
float score[N];
input(score, N);
output(score, N);
printf("\nAverage: %.2f\n", average(score,N));
return 0;
}
int fun(int x){
int i;
for (i=2;ix/2;i++)
if (x%i==0) return 0;
return 1;
}
#includestdio.h
#includestring.h
void selectsort(double a[],int n);
void insert_push(double a[],int n, double *p); ///---
int main()
{
int i;
double number[10]={1,2,3,6,8,99,88,100,123,9};
double pushed;
selectsort(number,10);
printf("Please input a new number:");
scanf("%lf", pushed); //加
insert_push(number,10,pushed);
for(i=0;i10;i++)
{
printf("%lf\n",number[i]);
}
printf("the biggest number is:%lf\n", pushed ); //输出的是变量,不是函数名
return 0;
}
void selectsort(double a[],int n)
{
int i,j,k;
double t;
for(i=0;in-1;i++)
{
j=i;
for(k=i+1;kn;k++)
{
if(a[k]a[j])
j=k;
}
if(j!=i)
{
t=a[i];
a[i]=a[j];
a[j]=t;
}
}
}
void insert_push(double a[],int n,double *p ) //--------变量类型形参与实参要一致
{
int i,j,k;
k=*p;
if(ka[n-1]) //如果k最后一个数,被挤出的是最后一个数,否则,被挤出的是k,即*p
{
*p=a[n-1];
for(i=0;in;i++)
{
if(ka[i])
{
for(j=n-1;ji;j--)
{
a[j]=a[j-1];
}
a[i]=k;
break;
}
}
}
}
#include stdio.h
#include dos.h
//main()
void main() //我的编译器需要用void
{
float jia(float,float);
float jian(float,float);
float cheng(float,float);
float chu(float,float);
float a,b,c;
printf("Input a and b:\n ");
//scanf("%f %f,a,b\n");
scanf("%f %f",a,b);//格式!注意""的位置;scanf中不能有\n吧?
c=jia (a,b);
printf("%f+%f=%f\n",a,b,c);
c=jian(a,b);
printf("%f-%f=%f\n",a,b,c);
c=cheng(a,b);
//printf("%f*5f=%f",a,b,c);
printf("%f*%f=%f\n",a,b,c);//“5”-〉“%”;再来个换行吧
//if (b!=0) {c=chu(a,b);
if (b!=0) {c=chu(a,b);//";"用半角
printf("%f/%f=%f",a,b,c);}
else printf("The b is zero!");
}
float jia(float x,float y)
{
float h;
h=x+y;
return(h);
}
float jian(float xa,float ya)
{
float ha;
ha=xa-ya;
return (ha);
}
float cheng(float xb,float yb)
{
float hb;
hb=xb*yb;
return (hb);
}
float chu(float xc,float yc)
{
float hc;
hc=xc/yc;
return (hc);
}
//你说我容易吗?