موقع طلبة جامعة البحرين

يمكنك تصفح الموقع كزائر ولكن ندعوك لتسجيل عضوية خاصة بك لتحصل على كافة الصلاحيات مثل تنزيل ملفات المكتبة وقراءة تعليقات هيئة التدريس وغيرها. يمكنك الحصول على عضوية مجانية بالضغط على زر تسجيل. إذا قمت بالتسجيل مسبقا فيمكنك الضغط على زر دخول.

تسجيل دخول
  • قسم المكتبة الجامعية مغلق مؤقتا بعد الاستهداف التي تعرضت له بعض خدمات أمازون في البحرين، جاري استرجاع الملفات ونقلها إلى سيرفرات جديدة وسيتم بعدها اعادة افتتاح المكتبة

ITCS112 - ITCS104 - ITCS102 للفصل الصيفي 2014 - 2015

أي والله طلع lol :nosweat::RpS_blink:

لأن البرنامج إذا مسح حرف الحرف اللي بعده ياخذ مثل الموقع للحرف اللي قبل و البرنامج ما بيتأكد منه .. :smile2:
يعني لازم تخلون "
for loop " داخل وحده ثانية

كود:
for (int j=0;j<2;j++)

كود:
#include <iostream>
#include <string>
using namespace std;
int main ()
{
    string s;
    cout<<"enter string :";
    cin>>s;
    cout<<endl;
    
    for (int j=0;j<2;j++){
    for (int i=0;i<s.length();i++)
    {
        if (s[i]=='a'||s[i]=='A'||s[i]=='u'||s[i]=='U'||s[i]=='i'||s[i]=='I'||s[i]=='o'||s[i]=='O'||s[i]=='e'||s[i]=='E')
        {
            s.erase ( i , 1 );
        }
    }}
    cout<<s<<endl;
return 0;
}

لا ماله داعي تخلي 2 loops
المسألة بسيطة مجرد تضيف


PHP:
i--;

PHP:
#include <iostream>
#include <string>
using namespace std;
int main ()
{
    string s;
    cout<<"enter string :";
    cin>>s;
    cout<<endl;
    
    
    for (int i=0;i<s.length();i++)
    {
        if (s[i]=='a'||s[i]=='A'||s[i]=='u'||s[i]=='U'||s[i]=='i'||s[i]=='I'||s[i]=='o'||s[i]=='O'||s[i]=='e'||s[i]=='E')
        {
            s.erase ( i , 1 );
            i--;
        }
    }
    cout<<s<<endl;
    system("pause");
return 0;
}

نسألكم الدعاء
 


إيه ، لأن المقروض ما تحطين space في حال تحقق الـ if
​
عجل ويش انحط ؟ :RpS_tongue:

هو يبي نستخدم الفنكشنات تبع درس السترنق
و بعد يبي طريقة بحيث ان ما نغير بالاسم الأصلي
مجرد ينحذف الحروف الفاول و رتيرن لنفس الفيريابل الي يدخله اليوزر
هكو استخدمت الـ Length له :RpS_unsure:
ااممممم مادري والله
:RpS_unsure:
 
عجل ويش انحط ؟ :RpS_tongue:

هكو استخدمت الـ Length له :RpS_unsure:
ااممممم مادري والله
:RpS_unsure:

ما تحطين شيء هههههه :RpS_lol:
لأن لو مثلا أنا دخلت Hassan ... بيطلع لي الجواب H ss n ... و الفروض الجواب يطلع Hssn بدون Spaces
بس ما أدري والله ويش و ليش الدكتور قال خطأ :smile2: .. فإذا كان الفروض بالـ function فمو مكتوب في السؤال !!
​
 


ما تحطين شيء هههههه :RpS_lol:
لأن لو مثلا أنا دخلت Hassan ... بيطلع لي الجواب H ss n ... و الفروض الجواب يطلع Hssn بدون Spaces
بس ما أدري والله ويش و ليش الدكتور قال خطأ :smile2: .. فإذا كان الفروض بالـ function فمو مكتوب في السؤال !!
​

لأن هو طالب برنامج نستخدم فيه فنكشنات السترنق
بحيث ان الاسم يرجع الأساسي .. بس بدون الحروف الفاول
 
يلا سدحوا سؤال غيره .. :whistling:
فكونا
مليون صفحة على مثل السؤال .. :RpS_huh:
 
لأن هو طالب برنامج نستخدم فيه فنكشنات السترنق
بحيث ان الاسم يرجع الأساسي .. بس بدون الحروف الفاول

انا اشوف اغلبكم جاوب بأستخدام erase function
انا اللي اعرفه مو مطلوبة ، الا اذا هالسمستر شرحوها ليكم هذا شي ثاني
عموماً انا جاوبته بدون استخدامها erase

PHP:
#include <iostream>
#include <string>
using namespace std;

int main()
{
    string str;
    
    cout<<"Enter a word"<<endl;
    cin>>str;
    
    for(int i=0;i<str.length();i++){
            if(str[i]=='A'||str[i]=='a'||str[i]=='E'||str[i]=='e'||
            str[i]=='U'||str[i]=='u'||str[i]=='O'||str[i]=='o'||str[i]=='I'||str[i]=='i')
            {
            str=str.substr(0,i)+str.substr(i+1,str.length());
            i--;
            }
            }
    cout<<str<<endl;
    system("pause");
    return 0;
    }

نسألكم الدعاء
 
انا اشوف اغلبكم جاوب بأستخدام erase function
انا اللي اعرفه مو مطلوبة ، الا اذا هالسمستر شرحوها ليكم هذا شي ثاني
عموماً انا جاوبته بدون استخدامها erase

PHP:
#include <iostream>
#include <string>
using namespace std;

int main()
{
    string str;
    
    cout<<"Enter a word"<<endl;
    cin>>str;
    
    for(int i=0;i<str.length();i++){
            if(str[i]=='A'||str[i]=='a'||str[i]=='E'||str[i]=='e'||
            str[i]=='U'||str[i]=='u'||str[i]=='O'||str[i]=='o'||str[i]=='I'||str[i]=='i')
            {
            str=str.substr(0,i)+str.substr(i+1,str.length());
            i--;
            }
            }
    cout<<str<<endl;
    system("pause");
    return 0;
    }

نسألكم الدعاء

تقدر تخليها جذي ..
كود:
str=str.substr(0,i)+str.substr(i+1);
 
انا اشوف اغلبكم جاوب بأستخدام erase function
انا اللي اعرفه مو مطلوبة ، الا اذا هالسمستر شرحوها ليكم هذا شي ثاني
عموماً انا جاوبته بدون استخدامها erase

PHP:
#include <iostream>
#include <string>
using namespace std;

int main()
{
    string str;
    
    cout<<"Enter a word"<<endl;
    cin>>str;
    
    for(int i=0;i<str.length();i++){
            if(str[i]=='A'||str[i]=='a'||str[i]=='E'||str[i]=='e'||
            str[i]=='U'||str[i]=='u'||str[i]=='O'||str[i]=='o'||str[i]=='I'||str[i]=='i')
            {
            str=str.substr(0,i)+str.substr(i+1,str.length());
            i--;
            }
            }
    cout<<str<<endl;
    system("pause");
    return 0;
    }

نسألكم الدعاء

اي الحذف مو عندنا فمن جدي أفكر بشي ثاني

الفكرة شبيهة بالفكرة الي في بالي .. الاختلاف ان قلت بدخل فايند بالسالفة فعفست الاولي و التالي

و فيه شي بسأل عنه صح ذكرتني فيه

اصير نسوي جدي ؟

كود:
char x={a,A,u,U,e,E,o,O,i,I};
word.find(x);

?​
 
يلا عاد خلّص السؤال من زمان و أنتون بعدكم تتناقشون عليه :nosweat:
​
 
Five-letter word x is hidden in a string y such that the first two letters of x are the first two letters of y and the third letter of x is the middle letter of y and the last two letters of x are the last two letters of y. Note that y is any string wi th length greater than 5
For example, the 10-letter string grabcefgat hides the 5-letter word great.

Write a program that reads a string from the user and displays the hidden word extracted from the entered string using the function extract


PHP:
#include<iostream>
#include<string>
using namespace std;
int main()
{
    string x,y;
    int len;
    cin>>y;
    cout<<endl;
    len=y.length();
    x[0]=y[0];
    x[1]=y[1];
    x[2]=y[len/2];
    x[3]=y[len-2];
    x[4]=y[len-1];


    cout<<"x is: "<<x<<endl;
    
    system("pause");
    return 0;
}
البرنامج يشتغل..
بس اذا ندخل الانبوت النتيجة في الاوتبوت يطبعها سبيس(خالي ,, مافي نتيجة)

وين الغلط :RpS_blink:
 
يلا يوم حطينا لكم سؤال ..محد هني :sly:

:bleh:
 
Five-letter word x is hidden in a string y such that the first two letters of x are the first two letters of y and the third letter of x is the middle letter of y and the last two letters of x are the last two letters of y. Note that y is any string wi th length greater than 5
For example, the 10-letter string grabcefgat hides the 5-letter word great.

Write a program that reads a string from the user and displays the hidden word extracted from the entered string using the function extract


PHP:
#include<iostream>
#include<string>
using namespace std;
int main()
{
    string x,y;
    int len;
    cin>>y;
    cout<<endl;
    len=y.length();
    x[0]=y[0];
    x[1]=y[1];
    x[2]=y[len/2];
    x[3]=y[len-2];
    x[4]=y[len-1];


    cout<<"x is: "<<x<<endl;
    
    system("pause");
    return 0;
}
البرنامج يشتغل..
بس اذا ندخل الانبوت النتيجة في الاوتبوت يطبعها سبيس(خالي ,, مافي نتيجة)

وين الغلط :RpS_blink:

بالنسبة للـy، السايز يتحدد تلقائياً من خلال عدد الأحرف اللي يحطها اليوزر لكن الـx السايز غير محدد.. ما تقدر تروح للإندكس 4 مثلاً وانت ما تدري إذا هو موجود أو لا، مثلاً عندك صندوق فيه اغراض تبي تنقلهم لصندوق ثاني.. لازم تتأكد أن الصندوق الثاني فيه مكان كفاية
PHP:
	x=y.substr(0, 2);
	x+=y.substr((y.length()/2), 1);
	x+=y.substr((y.length()-2), 2);
 
Five-letter word x is hidden in a string y such that the first two letters of x are the first two letters of y and the third letter of x is the middle letter of y and the last two letters of x are the last two letters of y. Note that y is any string wi th length greater than 5
For example, the 10-letter string grabcefgat hides the 5-letter word great.

Write a program that reads a string from the user and displays the hidden word extracted from the entered string using the function extract


PHP:
#include<iostream>
#include<string>
using namespace std;
int main()
{
    string x,y;
    int len;
    cin>>y;
    cout<<endl;
    len=y.length();
    x[0]=y[0];
    x[1]=y[1];
    x[2]=y[len/2];
    x[3]=y[len-2];
    x[4]=y[len-1];


    cout<<"x is: "<<x<<endl;
    
    system("pause");
    return 0;
}
البرنامج يشتغل..
بس اذا ندخل الانبوت النتيجة في الاوتبوت يطبعها سبيس(خالي ,, مافي نتيجة)

وين الغلط :RpS_blink:
تره حليناه سابقًا (حلّاه Noise) ... بس كنت أنا ما أعرف الحل لأن مو مطلوب علينا كان الـ string ... بس ألحين بحاول أحله :smile2:
​
 
Five-letter word x is hidden in a string y such that the first two letters of x are the first two letters of y and the third letter of x is the middle letter of y and the last two letters of x are the last two letters of y. Note that y is any string wi th length greater than 5
For example, the 10-letter string grabcefgat hides the 5-letter word great.

Write a program that reads a string from the user and displays the hidden word extracted from the entered string using the function extract

طبعًا هذا جوابي ... بس مو متأكد منه :RpS_unsure:
PHP:
#include<iostream>
#include<string>
using namespace std;
int main(){
    string word; int size;
    cin>>word;
    size=word.size();
    
    cout<<word.substr(0,2)
        <<word.substr(2+3,1)
        <<word.substr(size-2,2);
    
    return 0;
}
 
اي الحذف مو عندنا فمن جدي أفكر بشي ثاني

الفكرة شبيهة بالفكرة الي في بالي .. الاختلاف ان قلت بدخل فايند بالسالفة فعفست الاولي و التالي

و فيه شي بسأل عنه صح ذكرتني فيه

اصير نسوي جدي ؟

كود:
char x={a,A,u,U,e,E,o,O,i,I};
word.find(x);

?​

اي يصير
بس في خطأ syntax

مايصير تقولين x هي char وانتي حاطه فيها اكثر من حرف

بالنسبة الى


PHP:
 :word.find(x);

لو كانت x متغير من نوع char كلشي اوكي
بس بما ان احنا خلينا فيها اكثر من حرف يعني هي string
طيب ، الحين
عندنا string x ومخلين فيه عدة حروف
من خواص ال
string انها مثل الArray فيها index

يعني مثلاً :
PHP:
string str="uob";
حرف الu في اندكس 0 ........ الخ

لهذا السبب مايصير اقول :


PHP:
word.find(x);

لان x هي من نوع string وفيها اكثر من حرف فلازم نفتر على كل حرف ( using loop )

فـ بكون الصيغة الصحيحة

PHP:
  for(int i=0 ; i<y.length() ;i++)
  cout<<word.find(y[i])<<endl;


بالنسبة للشرط مال الloop
اما اكتب عدد الحروف اللي
خليتها في المتغير x
او ا
قدر استخدم ال function اللي تحسب لي

هذا كود بسيط يوضح العملية

PHP:
#include<iostream>
#include<string>

using namespace std;

int main(){
    
   string x("uob");
   string word;
  
  cout<<"Enter word "<<endl;
  cin>>word;
      
  for(int i=0 ; i<x.length() ;i++)
  cout<<word.find(x[i])<<endl;

system("pause");
    return 0;
}

نسألكم الدعاء

 
طبعًا هذا جوابي ... بس مو متأكد منه :RpS_unsure:
PHP:
#include<iostream>
#include<string>
using namespace std;
int main(){
    string word; int size;
    cin>>word;
    size=word.size();
    
    cout<<word.substr(0,2)
        <<word.substr(2+3,1)
        <<word.substr(size-2,2);
    
    return 0;
}

No
 
عودة
أعلى أسفل