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

Обсуждение задачи 1003. Чётность

Показать все сообщения Спрятать все сообщения

Reading strings on C++ Igor E. Tuphanov 6 янв 2006 09:54
Strange. It's already second prob., wich got WA #1, where I've got to read strings from input.
FE, in this prob., I used two methods reading word in the end of line (all tests, I tested my solution were correct):

      cin.getline(ss,sizeof(ss)); s.assign(ss);
      while (s[0] == ' ') s.erase(s.begin());
      while (s[s.length()-1] == ' ') s.erase(s.begin() + s.length() - 1);
      if (s == "odd") p[i] = 1; else p[i] = 0;

And the second one:

      scanf("%s",ss);
      if (ss[0] == 'o') p[i] = 1; else p[i] = 0;

Both got WA #1. Am I wrong?

Edited by author 06.01.2006 09:56
Re: Reading strings on C++ Igor E. Tuphanov 7 янв 2006 08:06
As I can see now, this prob. is kind of stupid. Everyone got WA #1. Or bug was fixed?
Re: Reading strings on C++ wsogenius 16 ноя 2007 15:06
hi guy this program may help you:)

#include <iostream>
#include <iomanip>
#inlcude <string>

using namespace std;

int main()
{
   string aStr;
   getline(cin,aStr);
   cout<<aStr<<endl;
   getline(cin,aStr,"\n");
   cout<<aStr<<endl;
}