Здравствуйте!!!!!! Эта программа "тест".Как думаете, что еще можно задействовать в этой программе???Как можно усовершенствовать? Может добавить функцию какую...
C++ |
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
| #include "stdafx.h"
#include <iostream>
#include <math.h>
#include <windows.h>
#include <cstdio>
using namespace std;
struct
{
char Name [20];
char sName[20];
char group[20];
char subject [20];
char pin [5];
} student;
struct
{
char Name [20];
char sName[20];
char group[20];
char subject [20];
char pin [5];
} students[20];
struct
{
char quetion[10000];
char v[2];
} quetions[24];
int _tmain(int argc, _TCHAR* argv[])
{
SetConsoleCP(1251);
SetConsoleOutputCP(1251);
char answer[20][2];
char st[100000];
FILE* f = fopen("student.txt","r");
if(f != NULL)
{
int i=0;
char ch;
int j=1;
while((ch = getc(f)) != '*')
{
st[i++]=ch;
j=j+1;
}
st[i] = '\0';
}
else printf("Error for open txt.\n");
fclose(f);
int k=0;
int k1=0;
int jj=0;
int j11=0;
int j12=0;
int j13=0;
int j14=0;
int j15=0;
for (int j=0; j<9990; j++)
{
if (st[j]=='|') {k1=k1+1; }
if (k1==1 && st[j]!='|') { students[jj].Name[j11]=st[j]; j11=j11+1; }
if (k1==2 && st[j]!='|') { students[jj].sName[j12]=st[j]; j12=j12+1; }
if (k1==3 && st[j]!='|') { students[jj].group[j13]=st[j]; j13=j13+1; }
if (k1==4 && st[j]!='|') { students[jj].subject[j14]=st[j]; j14=j14+1; }
if (k1==5 && st[j]!='|') { students[jj].pin[j15]=st[j]; j15=j15+1; }
if (k1==6){k1=1; jj=jj+1;
j11=0; j12=0; j13=0; j14=0; j15=0; }
}
cout<<"Введите имя \n";
cin>>student.Name;
cout<<"Введите фамилию \n";
cin>>student.sName;
cout<<"Введите группу \n";
cin>>student.group;
cout<<"Введите предмет, который сдаете \n";
cin>>student.subject;
cout<<"Введите ПИН \n";
cin>>student.pin;
for(int i=0; i<15; i++ )
{ if((strcmp(students[i].Name,student.Name)==0) &&
(strcmp(students[i].sName,student.sName)==0)&&
(strcmp(students[i].group,student.group)==0) &&
(strcmp(students[i].subject,student.subject)==0)&&
(strcmp(students[i].pin,student.pin)==0) )
{cout<<"You can start make your test \n";
FILE* f1 = fopen("quetion1.txt","r");
if(f1 != NULL)
{
int i=0;
char ch;
int j=1;
while((ch = getc(f1)) != '*')
{
st[i++]=ch;
j=j+1;
}
st[i] = '\0';
}
else printf("Error for open txt.\n");
fclose(f1);
k=0;
k1=0;
jj=0;
j11=0;
j12=0;
jj=0;
for (int j=0; j<99000; j++)
{
if (st[j]=='|') {k1=k1+1; }
if (k1==0) {quetions[jj].quetion[j11]=st[j]; j11=j11+1; }
if (k1==1) {quetions[jj].v[j12]=st[j+1]; j12=j12+1;}
if (k1==2){k1=0; jj=jj+1; j11=0; j12=0;}
}
cout<<jj;
for ( int j=0; j<jj; j++)
{ cout<<quetions[j].quetion<<"\n";
cin>>answer[j][1];
}
int l=0;
k=0;
for (int j=0; j<jj; j++)
{
if(answer[j][1]==quetions[j].v[0]) { l=l+1;}
if(answer[j][1]!=quetions[j].v[0]) { k=k+1;}
}
cout<<" L="<<l;
cout<<" k="<<k<<"\n";
int i;
for (int j=0; j<jj; j++)
{
if(answer[j][1]==quetions[j].v[0]) { cout<<j+1<<" right \n";}
if(answer[j][1]!=quetions[j].v[0]) {cout<<j+1<<" no right \n";}
}}}
system("pause");
return 0;
} |
|