Ali Hassan
اا مشرف سابق اا
- تاريخ التسجيل
- 30 سبتمبر 2011
- المشاركات
- 7,379
- المجموعة
- ذكر
- الدفعة الدراسية
- معلومة خاصة
- التخصص
- 0
ما في شيء جديد ؟ 


#include<iostream>
#include<string>
using namespace std;
int main()
{
string s,word;
int len,lens,position;
cout<<" enter a string :";
getline(cin,s);
cout<<endl;
cout<<"enter a word :";
cin>>word;
cout<<endl;
len=word.length();
lens=s.length();
for (int i=0;i<lens;i++)
{
position=s.find(word);
if (position>=0 && position<lens)
s.erase(position,len);
}
cout<<"the new string is :"<<s<<endl;
return 0;
}
اعتقد جدي الحل :write a function called "insertcomma" that takes a string" sentence" as input parameter and returns the new sentence after inserting comma before each space in the sentence
#include<iostream>
#include<string>
using namespace std;
string insertcomma(string str1){
int size=str1.size();
for(int i=0;i<size;i++){
if(str1[i]==' '){str1[i]=', ';}
}
return str1;}
int main(){
string str1;
getline(cin,str1);
cout<<insertcomma(str1);
return 0;}
// Ali Hassan
اعتقد جدي الحل :
PHP:#include<iostream> #include<string> using namespace std; string insertcomma(string str1){ int size=str1.size(); for(int i=0;i<size;i++){ if(str1[i]==' '){str1[i]=',';} } return str1;} int main(){ string str1; getline(cin,str1); cout<<insertcomma(str1); return 0;} // Ali Hassan
write a program that reads two strings , sentence and word , from the user and display the new sentence after removing all occurrences of word in the sentence >> اني حليته بال erase اذا ممكن تحلونة بطريقه ثانيه
PHP:#include<iostream> #include<string> using namespace std; int main() { string s,word; int len,lens,position; cout<<" enter a string :"; getline(cin,s); cout<<endl; cout<<"enter a word :"; cin>>word; cout<<endl; len=word.length(); lens=s.length(); for (int i=0;i<lens;i++) { position=s.find(word); if (position>=0 && position<lens) s.erase(position,len); } cout<<"the new string is :"<<s<<endl; return 0; }

#include<iostream>
#include<string>
using namespace std;
int main()
{
string s,word;
int len,lens,position,x;
cout<<"enter a string :\n";
getline(cin,s);
cout<<endl;
cout<<"enter a word :\n";
cin>>word;
cout<<endl;
len=word.length();
lens=s.length();
for (int i=0;i<lens;i++)
{
position=s.find(word);
if (position!=-1)
s=s.substr(0,position)+s.substr(position+len);
}
cout<<"the new string is :\n"<<s<<endl;
system("pause");
return 0;
}
if (position!=string::npos)
write a function called "insertcomma" that takes a string" sentence" as input parameter and returns the new sentence after inserting comma before each space in the sentence

#include<iostream>
#include<string>
using namespace std;
string insertcomma(string str)
{
int size=str.size();
for(int i=0;i<size;i++){
i=str.find(' ',i+1);
if(str.find(' ',i)==-1) break;
else str=str.substr(0,str.find(' ',i))+","+str.substr(str.find(' ',i));}
return str;
}
int main()
{
string sentence;
getline(cin,sentence);
cout<<insertcomma(sentence)<<endl;
system("pause");
return 0;
}
صحيييح#include<iostream>
#include<string>
using namespace std;
int main()
{
string s,word;
int len,lens,position,x;
cout<<"enter a string :\n";
getline(cin,s);
cout<<endl;
cout<<"enter a word :\n";
cin>>word;
cout<<endl;
len=word.length();
lens=s.length();
for (int i=0;i<lens;i++)
{
position=s.find(word);
if (position!=-1)
s=s.substr(0,position)+s.substr(position+len);
}
cout<<"the new string is :\n"<<s<<endl;
system("pause");
return 0;
}
وينك ما تجي تغششنا في اللاب#include<iostream>
#include<string>
using namespace std;
string insertcomma(string str)
{
int size=str.size();
for(int i=0;i<size;i++){
i=str.find(' ',i+1);
if(str.find(' ',i)==-1) break;
else str=str.substr(0,str.find(' ',i))+","+str.substr(str.find(' ',i));}
return str;
}
int main()
{
string sentence;
getline(cin,sentence);
cout<<insertcomma(sentence)<<endl;
system("pause");
return 0;
}

#include<iostream>
using namespace std;
int main()
{
int list[]={2,9,4,3,8,1,7};
int temp;
for (int i=0;i<7;i++)
{
for (int j=0;j<7-i-1;j++)
{
if (list[j]>list[j+1])
{
temp=list[j];
list[j]=list[j+1];
list[j+1]=temp;
}
}
}
for (int x=0;x<7;x++)
cout<<list[x]<<endl;
return 0;
}
صحيييح![]()
وينك ما تجي تغششنا في اللاب![]()


جبت لكم اليوم برنامج بسيط حق درس الbubble sorting / chapter 10PHP:#include<iostream> using namespace std; int main() { int list[]={2,9,4,3,8,1,7}; int temp; for (int i=0;i<7;i++) { for (int j=0;j<7-i-1;j++) { if (list[j]>list[j+1]) { temp=list[j]; list[j]=list[j+1]; list[j+1]=temp; } } } for (int x=0;x<7;x++) cout<<list[x]<<endl; return 0; }

#include<iostream>
using namespace std;
int main()
{
int list[]={2,9,4,3,8,1,7};
int temp;
for (int i=0;i<7;i++)
{
for (int j=i+1;j<7;j++)
{
if (list[i][COLOR=#ff0000]>[/COLOR]list[j])
{
temp=list[i];
list[i]=list[j];
list[j]=temp;
}
}
}
for (int x=0;x<7;x++)
cout<<list[x]<<" ";
cout<<endl;
system("pause");
return 0;
}
if (list[i][COLOR=#ff0000]<[/COLOR]list[j])
write a fuction reverse that reverses a string passed as a parameter , assume the function prototype is " void reverse(string &s)بنرد نرجعكم لدرس السترنقwrite a fuction reverse that reverses a string passed as a parameter , assume the function prototype is " void reverse(string &s)
#include<iostream>
#include<string>
using namespace std;
void reverse(string &s)
{
for (int i=s.length()-1;i>=0;i--)
cout<<s[i];
cout<<endl;
}
int main()
{
string v;
v="victory";
reverse(v);
return 0;
}


write a function NoDupplication which takes a string as a parameter and removes all repetitions of characters from it , assume the function prototype is " string NoDupplication(string s)" ,,, then write a program for the function ,, مو مطلوب program بس من عندي حق الاستفاده![]()
#include<iostream>
#include<string>
using namespace std;
string NoDupplication(string s)
{
for (int i=0;i<s.size();i++)
if (s[i]==s[i+1])
{s.erase(i,1);i--;}
return s;
}
int main()
{
string str;
getline(cin,str);
cout<<NoDupplication(str)<<endl;
system("pause");
return 0;
}




HTML:#include <iostream> #include <string> #include <fstream> using namespace std; int main() { string str; int min=100; ifstream in;in.open("name.txt"); ofstream out;out.open("length.txt"); if (!in){cout<<"Erorr no file";return 1;} while(!in.eof()) { in>>str; out<<str.length()<<endl; if (str.length()<min)min=str.length(); } cout<<"Maimum name size : "<<min<<endl; system("pause"); return 0; }
وينك ما تجي تغششنا في اللاب
راحوا الطيبيناللي ويايي في سكشن ما اقصر وياهم ..
ما تجي الدكتورة إلا الكل مخلص ..![]()
بالنسبة لذا البرنامج لو بغيت اطلع ليي ال length مع ال spaces مثلا ali jasem بغيته يطلع 9 مو يطبع كل كلمة بروحها
و ال min مثل الشيء يطلع اقصر اسم بالسبيسات![]()
ان شاء الله فاهميني![]()
![]()
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int main()
{
string str;
int min=100;
ifstream in;in.open("name.txt");
ofstream out;out.open("length.txt");
if (!in){cout<<"Erorr no file";return 1;}
while(!in.eof())
{
getline(in,str);
out<<str.length()<<endl;
if (str.length()<min)min=str.length();
}
cout<<"Maimum name size : "<<min<<endl;
system("pause");
return 0;
}
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int main()
{
string str;
int x=10 , y=10;
ifstream in;in.open("names.dat");
ofstream out;out.open(" namelength.dat");
if (!in)
{
cout<<"Sorry No File";
return 1;
}
while(!in.eof())
{
getline(in,str);
out<<str.length()<<endl;
if (str.length()>x)
x=str.length();
else if (str.length()<y)
y=str.length();
}
cout<<"Maxmum name size : "<<x<<endl;
cout<<endl;
cout<<"Maimum name size : "<<y<<endl;
system("pause");
return 0;
}
