19.05.2013, 03:17. Просмотров 302. Ответов 1
C++ | 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
| #include <iostream>
using namespace std;
#include <string>
int main()
{
string firstWord;
cout << "Input the word: ";
cin >> firstWord;
char lastLetter(firstWord.at(firstWord.length() - 1));
string currentWord;
do {
cout << "The last letter: " << lastLetter <<endl;
cout << "Input the word beginning on '" << lastLetter << "': " <<endl;
cin >> currentWord;
lastLetter = currentWord.at(0) == lastLetter ? currentWord.at(currentWord.length() - 1) : lastLetter;
} while (currentWord != "exit" || currentWord.at(0) == lastLetter);
cin.get();
cin.get();
return 0; |
|
0
|