#include <iostream> #include <stdio.h> using namespace std; int main() { short int chars[26] = {0}; char str[257] = {'\0'}; char c; int pos = 0; int len = 0; int count = 0; bool flag; cout<<"String: "; cin.getline(str, 255); cout<<"Result"<<endl; len = strlen(str); str[len + 1] = '\0'; str[len] = ' '; len++; for(int i = 0; i < len; i++) { if(str[i] == ' ') { flag = true; for(int j = 0; j < 26; j++) { if(chars[j] > 1) { flag = false; break; } } if(flag) { count++; for(int j = pos; j < i; j++) { cout<<str[j]; } cout<<endl; } for(int j = 0; j < 26; j++) { chars[j] = 0; } pos = i + 1; } else { c = tolower(str[i]); if(c >= 'a' && c <= 'z') { chars[c - 'a']++; } } } if(count == 0) { cout<<"No words"<<endl; } getchar(); return 0; } |