pex10_4.cpp

来自「数据结构C++代码,经典代码,受益多多,希望大家多多支持」· C++ 代码 · 共 45 行

CPP
45
字号
#include <iostream.h>
#pragma hdrstop

#include "wex10_9.h"
#include "strclass.h"

void main(void)
{
	// all palindromes we find are stored in s
	String s[50], current;
	// number of palindromes we find
	int numStrings = 0;

	// read whitespace separated words until end of file
	while(cin >> current)
		// if a word is a palindrome, insert it into s and
		// increment the count numStrings
		if (pal(current,0,current.Length()-1))
			s[numStrings++] = current;
			
	// print the palindromes we found
	cout << "The palindromes are: " << endl << endl;
	for(int i=0;i < numStrings;i++)
		cout << s[i] << endl;
}

/*
<Run>

dad
horse
level
arithmetic
madamimadam
computers
amanaplanacanalpanama

The palindromes are:

dad
level
madamimadam
amanaplanacanalpanama
*/

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?