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

Обсуждение задачи 1496. Спамер

Crash (Acess Violation) on case # 6?
Послано HappyPerson 11 июл 2012 00:29
Code:


#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{int spammers; char peeps[33][101]; bool k=true;
    cin>>spammers;
    for(int i=0; i<=spammers; i++)
    {
            peeps[31][i]=0;
            peeps[32][i]=0;
            for(int g=0; peeps[g-1][i]!='\n'; g++)
            {
                    cin.get(peeps[g][i]);
                    peeps[31][i]+=peeps[g][i];
                    peeps[32][i]++;
            }
    }
    for(int i=0; i<=spammers-1; i++)
    {
               for(int g=i+1; g<=spammers; g++)
               {
                       if(peeps[31][i]==peeps[31][g] && peeps[32][i]==peeps[32][g] && peeps[31][g]!=-1)
                       {
                                                     if(k==true)
                                                     {
                                                     peeps[31][g]=-1;
                                                     for(int y=0; peeps[y-1][g]!='\n'; y++)
                                                     {
                                                             cout<<peeps[y][g];
                                                     }
                                                     k=false;
                                                     }
                                                     else
                                                     {
                                                         peeps[31][g]=-1;
                                                     }
                       }
               }
               k=true;
    }
    system("PAUSE");
    return EXIT_SUCCESS;
}





Any ideas why it crashes?
Use "reference vector<T>::at(size_t i);", Luke!
Послано Artem Khyzha 11 июл 2012 00:47
Sorry, your code is kind of too obfuscated for lazy me, but I would believe that you've really got access violation in your program. If you're curious, replace all arrays with vectors and use range checking access via "at".