- تاريخ التسجيل
- 14 سبتمبر 2012
- المشاركات
- 2,834
- المجموعة
- ذكر
- الدفعة الدراسية
- 2012
- الكلية
- كلية تقنية المعلومات
- التخصص
- CS - متقاعد
الشعب قاموا يحلون بدوني ..سؤال خفيف شوي
Write a program that prompts the user to input a string. The program then should remove all the vowels from the string and output the new string. For example, if str=”There”, then after removing all the vowels, str=”Thr”. ”.

- اعترف تورطت شوي بس عرفت وين المشكلة

كود:
#include <iostream>
#include <string>
using namespace std;
char check (char x)
{
if (x=='i'||x=='o'||x=='e'||x=='u'||x=='a'||x=='I'||x=='O'||x=='E'||x=='U'||x=='A')
return '1';
else return x;
}
int main()
{
string str,a,b;
getline(cin,str);
for (int i=0;i<str.length();i++)
{
for (int i=0;i<str.length();i++)
{
if (check(str[i])=='1')
str.erase(i,1);
else
str[i]=check(str[i]);
}
}
cout<<str<<endl;
system("pause");
return 0;
}
ونقدر نستخدم بدل " erase " ..

كود:
{
a=str.substr(0,i);
b=str.substr(i+1);
str=a+b;
}




