史萊姆論壇
(
http://forum.slime.com.tw/)
-
程式語言討論區
(
http://forum.slime.com.tw/f76.html)
- -
求矩形面積
(
http://forum.slime.com.tw/thread218925.html)
求矩形面積
輸入長和寬
並求出面積
呼叫面積函數
不知哪裡錯誤
請高手指導
語法:
#include<stdio.h>
#include<stdlib.h>
float rectangle(float,float);
int main(){
float a,b;
printf("請輸入長和寬\n");
scanf("長%f\n",&a);
scanf("寬%f\n",&b);
printf("矩形的面積%f\n",rectangle(a,b));
system("PAUSE");
return 0;
}
float rectangle(float x,float y){
return x*y;
}
|
getter |
2007-10-25 04:38 AM |
語法:
#include<stdio.h>
#include<stdlib.h>
float rectangle(float,float); //這裡錯了
應該跟副程式的一致 float rectangle(float x,float y);
int main(){
float a,b;
printf("請輸入長和寬\n");
scanf("長%f\n",&a); // 這裡也怪怪的,當我按下 Enter 時,下一行的 scanf 就被強制略過了。
scanf("寬%f\n",&b); // 這裡也怪怪的同上一行
printf("矩形的面積%f\n",rectangle(a,b));
system("PAUSE");
return 0;
}
float rectangle(float x,float y){
return x*y;
}
修正如下
語法:
#include<stdio.h>
#include<stdlib.h>
float rectangle(float x,float y);
int main()
{
float a,b;
printf("請輸入長\n");
scanf("%f",&a);
printf("請輸入寬\n");
scanf("%f",&b);
printf("\n矩形的面積 %.3f\n",rectangle(a,b));
system("PAUSE");
return 0;
}
float rectangle(float x,float y){
return x*y;
}
|
所有時間均為台北時間。現在的時間是 02:57 AM。 |
|
Powered by vBulletin® 版本 3.6.8
版權所有 ©2000 - 2024, Jelsoft Enterprises Ltd.
『服務條款』
* 有問題不知道該怎麼解決嗎?請聯絡本站的系統管理員 *