#include stdio.h
創(chuàng)新互聯(lián)公司專業(yè)為企業(yè)提供三沙網(wǎng)站建設(shè)、三沙做網(wǎng)站、三沙網(wǎng)站設(shè)計(jì)、三沙網(wǎng)站制作等企業(yè)網(wǎng)站建設(shè)、網(wǎng)頁(yè)設(shè)計(jì)與制作、三沙企業(yè)網(wǎng)站模板建站服務(wù),10余年三沙做網(wǎng)站經(jīng)驗(yàn),不只是建網(wǎng)站,更提供有價(jià)值的思路和整體網(wǎng)絡(luò)服務(wù)。
#include string.h //增加此行
double jia()
{ char n[4]; //此行有改動(dòng)
double i,j,min;
int k,m=225;
printf("請(qǐng)輸入兩個(gè)數(shù)字: (中間用一個(gè)空格隔開(kāi))");
for(k=0; km; ++k)
{ scanf("%lf %lf",i,j);
min = i + j;
printf("是否繼續(xù)(只輸入小寫(xiě)yes或者小寫(xiě)no)");
scanf("%s",n); //此行有改動(dòng)
if(strcmp(n,"yes")==0) //此行有改動(dòng)
continue;
}
return min;
}
double jian()
{ double i,j,min;
printf("請(qǐng)輸入兩個(gè)數(shù)字: (中間用一個(gè)空格隔開(kāi))");
scanf("%lf %lf",i,j);
min = i - j;
return min;
}
double cheng()
{ double i,j,min;
printf("請(qǐng)輸入兩個(gè)數(shù)字: (中間用一個(gè)空格隔開(kāi))");
scanf("%lf %lf",i,j);
min = i * j;
return min;
}
double chu()
{ double i,j,min;
printf("請(qǐng)輸入兩個(gè)數(shù)字: (中間用一個(gè)空格隔開(kāi))");
scanf("%lf %lf",i,j);
min = i / j;
return min;
}
int main()
{ char q;
printf("請(qǐng)輸入運(yùn)算方式: (+ - * /,注:只能是括號(hào)里面的,不能是文字)");
scanf("%c",q);
switch(q)
{ case '+':
printf("%lf",jia());
break;
case'-':
printf("%lf",jian());
break;
case'*':
printf("%lf",cheng());
break;
case'/':
printf("%lf",chu());
break;
}
return 0;
}
#includestdio.h
double jia(double a,double b){
return a+b;}
double jian(double a,double b){
return a-b;}
double cheng(double a,double b){
return a*b;}
double chu(double a,double b){
return a/b;}
int modd(int a,int b){
return a%b;}
int main(){
double a,b;
printf("輸入兩個(gè)數(shù)字\n");
scanf("%lf%lf",a,b);
printf("加 %lf\n減 %lf\n乘 %lf\n除 %lf\n取模 %d\n",jia(a,b),jian(a,b),cheng(a,b),chu(a,b),modd((int)a,(int)b));
return 0;}
1. jia函數(shù)要寫(xiě)在main前面, 或者在main前面加jia函數(shù)的聲明
2. jia函數(shù)的參數(shù)缺少數(shù)據(jù)類型了
試試下面的:
#include stdio.h
void jia(float a, float b)
{
float jia;
jia=a+b;
printf("%f",jia);
}
void main()
{
jia(1.1, 2.2);
getch();
}