30.05.2013, 17:14. Просмотров 183. Ответов 0
C++ |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
#include <conio.h>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <stdlib.h>
#include <string>
#include <algorithm>
using namespace std;
bool ispalind(string s);
int main()
{
std::ifstream input("in.txt");
std::string s;
while(std::getline(input, s))
ispalind (s);
system("pause");
return 0;
}
bool ispalind(string s)
{
std::ofstream output("out.txt");
int p;
string rs = s;
reverse(rs.begin(), rs.end());
p=(s == rs);
if (p)
output << s <<std::endl;
return s == rs;
} |
|
считывает с файла только последнюю строчку и проверяет на палиндрому, а надо чтоб проверяло каждую строчку.
Добавлено через 32 минуты
оказывается проверяются только слова на палиндромы, а фразы палиндромы не проверяются((