0% found this document useful (0 votes)
42 views2 pages

Prob 20

This C++ program contains functions to analyze words in a string. It takes a string as input, separates it into individual words, and outputs words that start with a consonant and end with a vowel or start with a vowel and end with a consonant. It also takes the input string, capitalizes words separated by spaces, and removes any vowels from each word before outputting the modified string.

Uploaded by

Cristian Diaconu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views2 pages

Prob 20

This C++ program contains functions to analyze words in a string. It takes a string as input, separates it into individual words, and outputs words that start with a consonant and end with a vowel or start with a vowel and end with a consonant. It also takes the input string, capitalizes words separated by spaces, and removes any vowels from each word before outputting the modified string.

Uploaded by

Cristian Diaconu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
You are on page 1/ 2

#include <iostream>

#include <fstream>
#include <string.h>
using namespace std;
void cuvinte(char s[71])
{
char *p,voc[6]="aeiou";
p=strtok(s," ");
while(p!=0)
{
if(strchr(voc,p[0])==0 && strchr(voc,p[strlen(p)-1])!=0)
cout<<p<<" ";
p=strtok(NULL," ");
}
}
int main()
{
char s[71],a[71],b[71],*p,voc[6]="aeiou";
int i;
ifstream f("atestat20.in");
ofstream g("atestat20.out");
f.get(s,71);
strcpy(a,s);
strcpy(b,s);
a[0]=a[0]-32;
for(i=0;i<strlen(a);i++)
if((a[i-1]==' '&&a[i]!=' ')||(a[i]!=' '&&a[i+1]==' '))
a[i]=a[i]-32;
a[strlen(a)-1]=a[strlen(a)-1]-32;
cout<<a<<endl;
cuvinte(s);

p=strtok(b," ");
for(i=0;i<strlen(p);i++)

if(strchr(voc,p[i])==0)
{
strcpy(p+i,p+i+1);
i--;
g<<p<<" ";
}

return 0;
}

You might also like