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 55 56 57 58 59 60 61 62 63 64 65 66 67
|
#include<iostream>
#include<string>
#include<fstream>
#include<sstream>
using namespace std;
int main()
{
int routin[6][7][6] = { 0 };
int teacherID,classCountOnCourse, courseID, creditHour, chunk, x, y, z, position, count_i = 0;
string stream_str;
stringstream _temp;
//This is what contails indata.txt
/*{
ofstream testDataStream("indata.txt");
for(int i = 0; i < 6; i++)
for(int j = 0; j < 7; j++)
for(int k = 0; k < 6 ; k++)
{
count_i++;
if(count_i <= 251)
testDataStream << i << j << k << " " << routin[i][j][k] << endl;
else
testDataStream << i << j << k << " " << routin[i][j][k];
}
testDataStream.close();
}*/
ifstream inStream("indata.txt");
ofstream outStream("outdata.txt");
cout << "Enter Teacher ID - ";
cin >> teacherID;
cout << "Enter class count - ";
cin >> classCountOnCourse;
for(int i=0; i<classCountOnCourse; i++)
{
cout << endl <<"For class# " << i << endl;
cout << "Enter CourseID, Credit Hour, Class Takes - ";
cin >> courseID >> creditHour >> chunk;
for(int j = 0; j<chunk; j++)
{
cout << endl << "Enter time slot(" << j << ")- ";
cin >> x >> y >> z;
position = 100*x + 10*y + z;
_temp << (teacherID * 100 + i);
inStream.seekg(0, ios::beg);
outStream.seekp(0, ios::beg);
while(getline(inStream, stream_str))
{
if(atoi(stream_str.substr(0,3).c_str()) == position)
stream_str.replace(4, 5, _temp.str());
outStream << stream_str << endl;
}
}
}
outStream.close();
inStream.close();
return 0;
}
|