برنامه ای به زبان سی پلاس پلاس برای حذف حروف صدادار، بیصدا، ارقام و فاصله ها در یک رشته
جمعه, ۱۶ مهر ۱۳۹۵، ۰۳:۴۴ ق.ظ
gameover.blog.ir
#include<iostream>
#include<cstring>
using namespace std;
int main(){
char line[150];
int i,v,c,ch,d,s,o;
o=v=c=ch=d=s=0;
cout << "Enter a line of string: " << endl;
cin.getline(line, 150);
for(i=0;line[i]!='\0';++i)
{
if(line[i]=='a'
|| line[i]=='e'
|| line[i]=='i'
|| line[i]=='o'
|| line[i]=='u'
|| line[i]=='A'
|| line[i]=='E'
|| line[i]=='I'
|| line[i]=='O'
|| line[i]=='U')
++v;
else if((line[i]>='a'&& line[i]<='z')
|| (line[i]>='A'&& line[i]<='Z'))
++c;
else if(line[i]>='0'&&c<='9')
++d;
else if (line[i]==' ')
++s;
}
cout << " Vowels: " << v << endl;
cout << " Consonants: " << c << endl;
cout << " Digits: " << d << endl;
cout << " White Spaces: " << d << endl;
return 0;
}
Output
Enter a line of string: programming is fun 1 234 Vowels: 5 Consonants: 11 Digits: 4 White Spaces: 4
۹۵/۰۷/۱۶