Se citeste un sir. Construiti si afisati 2 siruri care contin vocale, respectiv consoane
C++
Răspunsuri la întrebare
#include <iostream>
#include <string.h>
using namespace std;
int main()
{
char sir[255], sirvoc[255], sircons[255], voc[]="aeiouAEIOU";
int i, indvoc=-1, indcons=-1, lengsir;
cout << "introdu sir de caractere: ";
cin.getline(sir,255);
lengsir=strlen(sir);
for (i=0; i<lengsir; ++i)
{
if (strchr(voc,sir[i]))
{
++indvoc;
sirvoc[indvoc]=sir[i];
}
else
{
if ((sir[i]>'a' && sir[i]<='z')||(sir[i]>'A' && sir[i]<='Z'))
{
++indcons;
sircons[indcons]=sir[i];
}
}
}
cout << " Sirul vocalelor: " << "\n";
for (i=0; i<=indvoc; ++i)
cout << sirvoc[i];
cout << "\n" << " Sirul consoanelor: " << "\n";
for (i=0; i<=indcons; ++i)
cout << sircons[i];
return 0;
}