-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsubject.cpp
118 lines (107 loc) · 3.13 KB
/
subject.cpp
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
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#include "subject.h"
void subject :: get_details()
{
infile.open("non-redundant-rollno.out");
infile>>total_branches;
for(i = 0; i < total_branches; i++)
{
infile>>branch_name[i]>>sub_code[i]>>total_rno[i];
for(j = 0; j < total_rno[i]; j++)
{
infile>>rollno[i][j];
}
}
infile.close();
}
void subject :: arrange_rollno()
{
// Putting values of subject code into another array set_code
for(i = 0; i < total_branches; i++)
{
set_code[i] = sub_code[i];
}
// Removing redundancy from set_code array
total_code = total_branches;
for(k = 0; k < total_code; k++)
{
for(i = k+1; i < total_code; i++)
{
if(set_code[i] == set_code[k])
{
for(j = i; j < total_code; j++)
{
set_code[j] = set_code[j+1];
}
total_code--;
//i = i-1;
}
}
}
// Displaying values of set_code
cout<<"----------------------------------------------------"<<endl
<<"Non redundant subject codes"<<endl
<<"----------------------------------------------------"<<endl;
for(i = 0; i < total_code; i++)
{
cout<<'\t'<<set_code[i]<<'\n';
set_rno[i] = 0;
}
// adding roll nos
for(i = 0; i < total_branches; i++)
{
for(j = 0; j < total_code; j++)
{
if(set_code[j] == sub_code[i])
{
// cout<<"\nsub: "<<set_code[j]<<endl;
for(k = 0; k < total_rno[i]; k++)
{
set_rollno[j][(k + set_rno[j])] = rollno[i][k];
}
set_rno[j] += total_rno[i];
}
}
}
// displaying roll nos.
cout<<"----------------------------------------------------"<<endl
<<"Final Roll no array which is used for sitting plan"<<endl
<<"----------------------------------------------------"<<endl;
for(i = 0; i < total_code; i++)//SizeOfArray(set_rollno)
{
cout<<'\n'<<set_code[i]<<endl;
for(j = 0; j < set_rno[i]; j++)//SizeOfArray(set_rollno[0])
{
cout<<set_rollno[i][j]<<"\t";
}
}
outfile.open("roll.in");
outfile<<total_code<<endl;
for(i = 0; i < total_code; i++)//SizeOfArray(set_rollno)
{
outfile << set_code[i] << " ";
// outfile<<'\n'<<set_code[i]<<endl;
outfile<<set_rno[i]<<" ";
for(j = 0; j < set_rno[i]; j++)//SizeOfArray(set_rollno[0])
{
outfile<<set_rollno[i][j]<<" ";
}
outfile<<endl;
}
outfile.close();
}
/*void subject :: show_details()
{
cout<<"----------------------------------------------------"<<endl
<<"Input file"<<endl
<<"----------------------------------------------------"<<endl;
for(i = 0; i < total_branches; i++)
{
cout<<branch_name[i]<<'\t'<<sub_code[i]<<"\t"<<total_rno[i]<<endl;
for(j = 0; j < total_rno[i]; j++)
{
cout<<rollno[i][j]<<'\t';
}
cout<<'\n'<<endl;
}
}
*/