ENG  RUS Timus Online Judge
Online Judge
Problems
Authors
Online contests
Site news
Webboard
Problem set
Submit solution
Judge status
Guide
Register
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

## Discussion of Problem 2002. Test Task

WA4
Posted by Alexey Stulov 21 Feb 2015 19:38
please can anyone tell me what is the test of 4?????

#include <iostream>

#include <conio.h>

using namespace std;

struct abonent
{
short status;
};
int main()
{
short n, k = 0, j, compare, index;
char *part_str;
char str[80];
cin >> n;
abonent *peop = new abonent[n];
gets(str);
for (int i = 0; i < n; i++)
{
gets(str);
part_str = strtok(str, " ");
if (!(strcmp(part_str, "register")))
{
part_str = strtok(NULL, " ");
compare = 1;
for (j = 0; j < k; j++)
{
{
compare = 0;
break;
}
}
if (compare)
{
part_str = strtok(NULL, " ");
peop[k].status = 0;
k++;
cout << "success: new user added\n";
}
else
{
cout << "fail: user already exists\n";
}
}

{
part_str = strtok(NULL, " ");
compare = 1;
for (j = 0; j < k; j++)
{
{
compare = 0;
index = j;
break;
}
}
if (!compare)
{
part_str = strtok(NULL, " ");
{
if (peop[index].status)
{
cout << "fail: already logged in\n";
}
else
{
peop[index].status = 1;
cout << "success: user logged in\n";
}
}
else
{
}
}
else
{
cout << "fail: no such user\n";
}
}

if (!(strcmp(part_str, "logout")))
{
part_str = strtok(NULL, " ");
compare = 1;
for (j = 0; j < k; j++)
{
{
compare = 0;
index = j;
break;
}
}
if (!compare)
{
if (peop[index].status)
{
peop[index].status = 0;
cout << "success: user logged out\n";
}
else
{
cout << "fail: already logged out\n";
}
}
else
{
cout << "fail: no such user\n";
}
}
}
delete[] peop;
return 0;
}

Edited by author 24.02.2015 02:52