|
During the family day at TADIKA UPSI, acomputer system gaming competition is designed for 5-6 years old children. 3children are registered for the competition. In the competition, the childrenare required to enter 50 numbers. These numbers will be categorize into 3categories which are positive numbers, negative numbers and zeros. As aprogrammer you are required to write acomplete program in C++ to produce the output of the following tasks: a) total numbers that are entered bythe 3 children for each category (positive, negative and zero). b) themost category of number that are entered. c) displaytotal numbers for each category that are entered and most category number that areentered.
You should: a) Analyzethe problem (input, process and output). b) Drawa flow chart. c) Developa program based on the above flow chart.
d) Printout an output of the program.
我做了還是錯,誰可以幫我看看哪裏錯了嗎? 感激不盡~
#include <iostream.h> using namespace std;
int main() { int student; int number[50],x; int count[50]; char category; cout<<"*****Student*****"<<endl; for (student=0; student<=3; student++) { // penting cout<<"Enter your number:"; cin>>number[50]; for (x=0; x<=50; x++) { // 1 open cout<<"Enter your number:"; cin>>number[x]; } { if (number>0) { cout<<"Positive numbers."<<endl; } else if (number<0) { cout<<"Negative numbers."<<endl; } else if (number==0) { cout<<"Zero!"<<endl; } else { cout<<"Error."<<endl; } } // 1 close } // penting cout<<"The most category printed is: "<<endl; for (x=0; x<=50; x++) cout<<category<<endl;
system("PAUSE"); return 0; }
|