aircraft 0 Newbie Poster

cannot remove tne /n, because it will appear many times again

aircraft 0 Newbie Poster

oooo..like that.thak you ancient dragon.

aircraft 0 Newbie Poster

i dont know how to declare aTable. where to put it?

aircraft 0 Newbie Poster

How to correct it?
ompiling...
27.cpp
C:\Documents and Settings\ashida\My Documents\MASTER C++\main\27.cpp(21) : error C2065: 'aTable' : undeclared identifier
C:\Documents and Settings\ashida\My Documents\MASTER C++\main\27.cpp(21) : error C2109: subscript requires array or pointer type
C:\Documents and Settings\ashida\My Documents\MASTER C++\main\27.cpp(21) : error C2228: left of '.size' must have class/struct/union type
C:\Documents and Settings\ashida\My Documents\MASTER C++\main\27.cpp(22) : error C2065: 'setw' : undeclared identifier
Error executing cl.exe.

27.exe - 4 error(s), 0 warning(s)

#include <iostream>
#include <vector>
using namespace std;

int main ()
{
     const int ROWS = 10,
	           COLUMNS = 10;
/*---------
Declaration
---------*/
	
	vector< vector<double> >table(ROWS, vector<double>(COLUMNS, 0.0));   // 10 zero-initialized ints
  unsigned int i;

  // assign some values:
    for (int row = 0; row < table.size(); row++)
    
{
    cout << "Examcode:";
    for (int col = 0; col < aTable[row].size(); col++)
    cout << setw(8) << table[row][col];
    cout << endl;
}
    return 0;
}
aircraft 0 Newbie Poster

i need both of cout, but dont want it repeat each time of student...........

aircraft 0 Newbie Poster

How can in the output, I want ONLY ONE LINE from 1 to 99, the windows is not enough..

myvector contains: 0 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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 5
5 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
Press any key to continue

#include <iostream>
#include <vector>
using namespace std;

int main ()
{
  vector<int> myvector (100);   // 10 zero-initialized ints
  unsigned int i;

  // assign some values:
  for (i=0; i<myvector.size(); i++)
    myvector.at(i)=i;

  cout << "myvector contains:";
  for (i=0; i<myvector.size(); i++)
    cout << " " << myvector.at(i);

  cout << endl;

  return 0;
}
aircraft 0 Newbie Poster

How to make a correction, because I just want one line only.

aircraft 0 Newbie Poster
/*------------------------------
Programming to count the examids
------------------------------*/

#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <vector>
#include<iomanip>
using namespace std;

     struct student
{
     string studentid;
     vector <int> examcode;	
};

     int main()   
{
	 int mycount;

{
	
	{
     ifstream stream1 ("STA83STU.txt");

     if(!stream1)
{
     cout << "While opening a file an error is encountered" << endl;
}
     else
{
     cout << "File is successfully opened" << endl;
}	
     vector <student> students;
     student aStudent;
     string tempStudentID;
     bool readEntireFile = false;    // set to true when reach end of file
            
     stream1 >> tempStudentID;    //  read in student id of first student
     while (!readEntireFile)
{
     aStudent.studentid = tempStudentID;  // new student
     int tempExamCode;
     aStudent.examcode.clear ();
     stream1 >> tempExamCode;    // read in first exam code for this student
     aStudent.examcode.push_back (tempExamCode);  // add this exam code to current student's vector of exam codes
     bool newStudent = false;   // true when a new student id is encountered
     while (!newStudent && !readEntireFile)  
{
     if (stream1 >> tempStudentID)   // successfully read in student id
{
     if (tempStudentID.compare (aStudent.studentid) == 0)  // student id is same as before
{
     stream1 >> tempExamCode;   // read in exam code
     aStudent.examcode.push_back (tempExamCode); // add this exam code to this student;s vector of exam codes
}
     else
     newStudent = true;   // student id is different from before.  Therefore new student.
}
     else
     readEntireFile = true;  // end of file reached.  Want to exit inner and outer while loops
}   // if new student, do not repeat this while loop

     students.push_back (aStudent);   // no more …
aircraft 0 Newbie Poster

whats the different between two multidimensional vector and array?

aircraft 0 Newbie Poster

How to avoid the output for
10 appears 3 times.
20 appears 3 times.
repeat at each line. Im just want one only.


10 appears 3 times.
20 appears 3 times. s610
6 29 69 74 95 103 110 132

10 appears 3 times.
20 appears 3 times. s611
2 7 29 70 75 100 104 111

10 appears 3 times.
20 appears 3 times. Press any key to continue

for (int j = 0; j < students.at (i).examcode.size (); j++)
     cout << students.at (i).examcode.at (j) << "\t";   // output list of exam codes for this student
     cout <<"\n"<<endl;   
	 
/*------------------------
counting elements in array
------------------------*/
      
	  int myints[] = {10,20,30,30,20,10,10,20};   // 8 elements
      mycount = (int) count (myints, myints+8, 10);
      cout << "10 appears " << mycount << " times.\n";
aircraft 0 Newbie Poster

Hi,

can I combine int main() and void main() in 1 programming.??