Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- using std::cout;
- using std::cin;
- int findFirstVowel(char word[])
- {
- for (int i=0; i < strlen(word); i++)
- {
- if (word[i]=='a' || word[i]=='e' || word[i]=='i' || word[i]=='o' || word[i]=='u' || (word[i]=='y' && i!=0))
- return i;
- }
- }
- int main()
- {
- char word[20];
- char pigLatin[20];
- cout<<"Vnesi zbor po sopstven izbor:\t";
- cin>>word;
- int i= findFirstVowel(word);
- if(i == 0)
- {
- strcpy(pigLatin, word);
- strcat(pigLatin, "way");
- }
- else
- {
- int k=0;
- for(int j = i; j < strlen(word); j++)
- {
- pigLatin[k++]=word[j];
- }
- pigLatin[k]='\0';
- strncat(pigLatin, word, i);
- strcat(pigLatin, "ay");
- }
- cout<<"pigLatin of "<<word<< " is "<<pigLatin;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement