с++ - вопрос №836811

Напечатать сообщение «This is a C program» так, чтобы каждое слово располагалось в новой строке (указать не менее двух вариантов такого вывода).

Ответы

Вариант №1

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <iostream>
#include <string.h>

using namespace std;
int main()
{
const char *wrd=«This is a C porgram»;
int ch_sz=strlen(wrd)+1;
for (size_t cnt=0;cnt!=ch_sz;++cnt)
{
cout <<wrd[cnt]<<endl;}
system(«pause»);
return 0;

}

20.11.13

Вариант № 2

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <iostream>
#include <string.h>

using namespace std;
int main()
{
string word=«This is a Cprogram»;
for (int cnt=0;cnt!=word.size();++cnt)
{
cout <<word[cnt]<<endl;
}
system(«pause»);
return 0;
}

20.11.13

выф

22.11.13

Вариант №3

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <iostream>
#include <string.h>
#include <vector>

using namespace std;
int main()
{
string g=«This is a C program»;
for (string::iterator cb=g.begin();cb!=g.end();++cb)
{
cout <<*cb<<endl;
}

system(«pause»);
return 0;
}

22.11.13

Еva

Читать ответы
Посмотреть всех экспертов из раздела Учеба и наука > Информатика
Пользуйтесь нашим приложением Доступно на Google Play Загрузите в App Store