2010網際網路程式設計全國大賽 國中組 (初賽題目)
題目A: 迴文- #include <iostream>
- #include <cstdlib>
- #include <string>
- using namespace std;
- int main(void){
- int y = 0, z = 0, t = 0;
- int d[t];
- cin >> t;
- for (int i = 0;i < t;i++){
- char a[100];
- int c, b, g = 0;
-
- while (cin >> a){
- b = strlen(a);
- for(int i = 0;i < b;i++){
- if (a[i] == a[b-i]){
- y++;
- }else{
- z++;
- }
- }if (z = 0){
- for (int i = g;i < t;i++){
- d[i] = 1;
- g++;
- }
- }else{
- for (int i = g;i < t;i++){
- d[i] = 0;
- g++;
- }
- }
- }//while判斷式括號
- }//for迴圈括號
- for (int i = 0;i <= t;i++){
- if (d[i] = 1){
- cout << "yes" << endl;
- }else if (d[i] = 0){
- cout << "no" << endl;
- }
- }
-
- //system("pause");
- return 0;
- }
複製代碼 幫幫我啊!
輸入:
3
abcba
abba
abc
後都沒反應!! |