新聞中心
C語言函數(shù)題,請大佬幫忙
#include stdio.h
網(wǎng)站建設(shè)哪家好,找成都創(chuàng)新互聯(lián)!專注于網(wǎng)頁設(shè)計、網(wǎng)站建設(shè)、微信開發(fā)、小程序設(shè)計、集團企業(yè)網(wǎng)站建設(shè)等服務(wù)項目。為回饋新老客戶創(chuàng)新互聯(lián)還提供了柳河免費建站歡迎大家使用!
#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;
}
c語言子函數(shù)問題?
int?fun(int?x){
int?i;
for?(i=2;ix/2;i++)
if?(x%i==0)?return?0;
return?1;
}
C語言子函數(shù)調(diào)用糾錯
#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 ); //輸出的是變量,不是函數(shù)名
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最后一個數(shù),被擠出的是最后一個數(shù),否則,被擠出的是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;
}
}
}
}
關(guān)于c語言子函數(shù)的問題?
#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中不能有\(zhòng)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);
}
//你說我容易嗎?
分享題目:c語言子函數(shù)題目 c語言 子函數(shù)
網(wǎng)站路徑:http://ef60e0e.cn/article/dopdjjc.html