ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1446. Sorting Hat

nima xato
Posted by Yangiboyev Bekmurod 16 Jan 2012 23:57
#include <iostream>
#include <string>
using namespace std;
int main ()
 {
string s[2002];
unsigned int n;
bool t=false;
bool t1=false;
bool t2=false;
bool t3=false;
cin>>n;
for( int i=1;i<=2*n;i++)
{
cin>>s[i];
if("Slytherin"==s[i])
t=true;
if("Hufflepuff"==s[i])
t2=true;
if("Gryffindor"==s[i])
t1=true;
if("Ravenclaw"==s[i])
t1=true;
}
if(t)
{
cout<<"Slytherin:"<<endl;
for(int i=1;i<=n;i++)
if("Slytherin"==s[2*i])
cout<<s[2*i-1]<<endl;
cout<<endl;
}
if(t2)
{
cout<<"Hufflepuff:"<<endl;
for(int i=1;i<=n;i++)
{
if("Hufflepuff"==s[2*i])
cout<<s[2*i-1]<<endl;
}
cout<<endl;
}
if(t1)
{
cout<<"Gryffindor:"<<endl;
for(int i=1;i<=n;i++)
if("Gryffindor"==s[2*i])
cout<<s[2*i-1]<<endl;
}
if(t)
{
cout<<"Ravenclaw:"<<endl;
for(int i=1;i<=n;i++)
if("Ravenclaw"==s[2*i])
cout<<s[2*i-1]<<endl;
}
 return 0;
}
Re: nima xato
Posted by Sunnat 17 Jan 2012 18:21
Xatolaringiz juda ko'p, asosiy o'rindagi xato kiritish jarayonidagi xato! ya'ni "cin" operatori probel tashlanganda ham kiritish tugaganini bildiradi, ism esa 1 talik, 2-talik,3-talik... bo'lishi mumkin
Re: nima xato
Posted by Jo'rayeva Dildora 22 Jan 2012 14:46
cin.getline(s[i]) yana qanday xato
Re: nima xato
Posted by Yangiboyev Bekmurod 22 Jan 2012 14:48
"cin" tashqari yana nima xato