الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

تكفوووووون الفزززعة

بدأه rmg في 30 أبريل 2010 · 5 رد · 555 مشاهدة · في الأسئلة المجابة
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

ياااااااا جماااااااعة الخييييير ابي اعرف وش الخطأ بكوودي ممكن احد يتفضل علي ويعلمني ؟

Write C++ program that define an array of strings word as following:-

string Fruits ={"apple", "orange" , "banana",

"grape" , "pear" , "strawberry" ,

"berry" , "peach" , "dates" };

Your program should ask user to enter any kind of fruits, then search in your

array to verify if it's in the list or no. Then print one of the following massages

up to the searching result

output sample:

Enter a kind of fruit and I'll

Search in the Fruit's Array!

apple

apple** is in the Fruits list!**

Enter a kind of fruit and I'll

Search in the Fruit's Array!

Bread

Bread ** is not in Fruits list!**

وهذي محاولتي

#include <iostream>

#include<string>

using namespace std;

int key;

int main()

{

string Fruits[] ={"apple", "orange" , "banana","grape" , "pear" , "strawberry" ,

"berry" , "peach" , "dates" };

cout<< "Enter a kind of fruit and I'll Search in the Fruit's Array!"<<endl;

cin>> key;

int flag = 0; // set flag to off

for (int i=0;i<9;i++) // start to loop through the array

{

if (Fruits == key) // if match is found

{

flag = 1; // turn flag on

break ; // break out of for loop

}

}

if (flag) // if flag is TRUE (1)

{

cout<< i <<"** is in the Fruits list!**"<<endl;

}

else

{

cout<< i <<"** is not in the Fruits list!**"<<endl;

}

return 0;

}

#2

السلام عليكم

key المفروض يكون من النوع string لانه اسم وليس رقم.

بدل int key الي string key

1
tvquran_6.gif

#3

تصحيح الكود ..

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

int main()
{
string key;
string Fruits[] ={"apple", "orange" , "banana","grape" , "pear" , "strawberry" ,
"berry" , "peach" , "dates" };
cout<< "Enter a kind of fruit and I'll Search in the Fruit's Array!"<<endl;
cin>> key;
int flag = 0; // set flag to off
for (int i=0;i<9;i++) // start to loop through the array
{
if (Fruits == key) // if match is found
{
flag = 1; // turn flag on
break ; // break out of for loop
}
}
if (flag) // if flag is TRUE (1)
cout<<key<<"** is in the Fruits list!**"<<endl;
else
cout<<key<<"** is not in the Fruits list!**"<<endl;
system("pause");
}

المعذرة أخوي فهد .. ما أنتبهت لمشاركتك ..

تم تعديل هذه المشاركة بواسطة إشراقــه فجــر في 30 أبريل 2010 في 18:36

1

سبحآن الله وبحمده .. سبحآن الله العظيم .. ,

#4

يعطييييييييييييكم الف الف عااااافية ... ماقصرتوووا الله يجزاااكم الجنة ياااارب

طب السؤال هذا فيه احد يعرف له جواب ؟

Write a program that read one dimensional array that contain of five elements from the

user, then do the following:-

Print all yours array's elements.

Define function which receives your array and calculate the mean of array's

elements and print return it.

Define another function that find the maximum value from array's elements

and print also return it.

Print both the mean and maximum values.

#5

لو بحثتي شوي بتلقين كل الأسئلة المطلوبة عليكم موجودة بالمنتدى :lol: ..

#include<iostream>
using namespace std;
float mean (int x[]);
int max (int x[]);
int main()
{
        int element[5];
        cout<<"Please Enter the Element "<<endl;
        for (int i=0 ; i<5 ; i++)
                cin>>element;
        for (int i=0 ; i<5 ; i++)
                cout<<element<<endl;
        cout<<"The Mean : "<<mean(element)<<endl;
        cout<<"The Maximum Value : "<<max(element)<<endl;
        system("pause");
}
float mean (int x[])
{
float sum =0;
        for (int i=0 ; i<5 ; i++)
sum+=x;
return (sum/5); 
}
int max (int x[])
{
int max = x[0];
for (int i=0 ; i<5 ; i++)
if (max < x)
max = x;
return max;
}

موفقيـــن :happy: ..

1

سبحآن الله وبحمده .. سبحآن الله العظيم .. ,

#6

اشراااااااااقة فجر مشكوووورة عالجهد ... تسلمين يالغلاااا ... الله يسعدك قولي آآآآآمين

مواضيع مشابهة