First... on the right side of the box you are typing in is a picture menu labeled format.
Select your code (it turns blue) then hit <> Those are code tags. :)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
#include<iostream> // You need a space between include and <iostream>
using namespace std; // This is a bad practice, It's okay for this program level,
// but as soon as you get the chance read up on namespaces.
// The sooner you break this habit, the better you'll be.
int n_of_students, n_of_rows, n_of_seatsinarow;
// Those variable names are okay, but long. You'll be typing them
// quite a bit. You sure about those names?
// void main(){ NEVER.. EVER EVER EVER Even if Santa promises you a new
// choo choo for Christmas use void main...
int main(){
cin>> n_of_students >> n_of_rows >> n_of_seatsinarow;
// This will not work in C++. You need to print a line, then ask for input.
cout << "Maximum number of students is: " << n_of_seatsinarow/2 +n_of_seatsinarow%2 ;
// Wait a minute... where does the value for n_of_seatsinarow come from? You haven't declared this anywhere...
if (n_of_students < n_of_seatsinarow/2 + n_of_seatsinarow%2)
// You are missing the opening bracket for this block of code
cout <<
return 0; // ( required from int main )
}
|
Man, you jump right in there don't cha? Okay, let's back and plan this out. You don't have one line of code correct, except line 6. You need to catch up to the class young man.
You need a chart of the seats. How many rows? How many seats in a row?
How can we keep track of where a STUDENT is sitting? In what row? What seat?
I have an idea... Let try for the coveted two dimensional array.
student [n_of_rows] [n_of_seatsinarow]={-1};
// There you have your seats all lined up, and they = -1 (for the empty seats.
// another requirement for your project)
Google "C++ two dimensional arrays" and read up on them... I bet they'll help you a lot.
Here's one to get you started.
http://www.cplusplus.com/doc/tutorial/arrays/
You also need to read up on variables, assigning a value to them, cin, and functions. You have a lot to do.