各位大大 小弟遇上一ㄍ問題 就是如何做出輸入5個數字判別正數還是負數或者是零??? 請各位大大 幫幫忙 小弟在此感恩不盡^^
2007-10-12 19:51:49 · 3 個解答 · 發問者 無樂不做 1 in 電腦與網際網路 ➔ 程式設計
//使用DEV C++稍微修正樓上大大的程式碼
#include
using namespace std;
int main(void){
int a, i;
cout << "請輸入數字" << endl;
for( i = 0; i < 5; i++) {
cout << "第 " << i + 1 <<" 個:";
cin >> a;
if( a > 0)
cout << "正數" << endl;
else if( a < 0 )
cout << "負數" << endl;
else if(a == 0)
cout << "零" << endl;
}
system("PAUSE");
return 0;
}
2007-10-13 00:37:10 · answer #1 · answered by Ashley 7 · 0⤊ 0⤋
#include
#include
#include
int judge(int n)
{
return (n>0)?1:((n<0)?-1:0);
}
using namespace std;
int main(int argc, char** argv){
//=====START=====//
int n;
string str[]={"Negative","Zero","Positive"};
cout<<"Input a number: ",cin>>n;
cout<
system("PAUSE");
return 0;
}
2007-10-13 07:07:03 · answer #2 · answered by Big_John-tw 7 · 0⤊ 0⤋
int a[]=new int[5];
cout<<"請輸入數字"<
cout<<"第"<
cin>>a[i];
if(a[i]>0) cout<<"正數"<
應該是這樣吧~
在這裡打沒有偵錯~@@"'
2007-10-12 21:07:17 · answer #3 · answered by ? 1 · 0⤊ 0⤋