View Code of Problem 114

#include <iostream>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<string>
#include<algorithm>
#include <iomanip>
using namespace std;
int main() {
	char a[1000];
	//char b[1000];
	while (gets(a)!=NULL) {
		int len = strlen(a);
		int k = 0;
		int j = 0;
		int t = 0;
		for (int i = 0; i < len; i++) {
			if (isalpha(a[i])) {
				k++;
			}
			else {
				if (k != 0) {
						//t = i;
						for (int j = i-1; j >= i - k; j--) {
								cout << a[j];
						}
						k=0;
						cout << a[i];
				}
				else cout << a[i];
				
			}
		}
		//cout <<t;
		if (k != 0) {
		for (int j = len-1; j >=len - k; j--) {
			cout << a[j];
		}
		}
 
		cout << endl;
	}
}

Double click to view unformatted code.


Back to problem 114