ENG  RUSTimus Online Judge
Online Judge
Задачи
Авторы
Соревнования
О системе
Часто задаваемые вопросы
Новости сайта
Форум
Ссылки
Архив задач
Отправить на проверку
Состояние проверки
Руководство
Регистрация
Исправить данные
Рейтинг авторов
Текущее соревнование
Расписание
Прошедшие соревнования
Правила
вернуться в форум

Обсуждение задачи 1446. Волшебная шляпа

Panzer WA #1 C++ // Задача 1446. Волшебная шляпа 12 дек 2010 01:00
Why I have WA? On my computer everything is ok... Please Help.

Code:

#include <cstdlib>
#include <iostream>
#include <string>

using namespace std;

int main(int argc, char *argv[])
{
    int n;

    scanf("%d", &n);

    string *tab = new string [n*2];

    //-------------------INPUT------------------------

    for(int i=0; i<n*2; i++){
            getline(cin, tab[i]);
            }

    string *list = new string [n+7];

    //------------------Slytherin-----------------------
    int pos=0;  //pos - position
    list[pos]="Slytherin:";

    for(int i=0; i<n*2; i+=2){
            if(tab[i+1][0]=='S'){
                    pos++;
                    list[pos]=tab[i];
                    }
            }
    pos++;
    //------------------Hufflepuff-----------------------
    pos++;
    list[pos]="Hufflepuff:";

    for(int i=0; i<n*2; i+=2){
            if(tab[i+1][0]=='H'){
                    pos++;
                    list[pos]=tab[i];
                    }
            }
    pos++;
    //------------------Gryffindor-----------------------
    pos++;
    list[pos]="Gryffindor:";

    for(int i=0; i<n*2; i+=2){
            if(tab[i+1][0]=='G'){
                    pos++;
                    list[pos]=tab[i];
                    }
            }
    pos++;
    //------------------Ravenclaw-----------------------
    pos++;
    list[pos]="Ravenclaw:";

    for(int i=0; i<n*2; i+=2){
            if(tab[i+1][0]=='R'){
                    pos++;
                    list[pos]=tab[i];
                    }
            }

    //-------------------OUTPUT---------------------------

    for(int i=0; i<n+7; i++){
            cout << list[i] << endl;
            }

    delete [] tab;
    delete [] list;

    system("pause");
    return EXIT_SUCCESS;
}