ملتقى البرمجة
اهلا بك زائرنا الكريم ..
اذا كانت هذه هيالزيارة الاولى لك فاننا ندعوك الى التسجيل بالمنتدى او التعريف بنفسك
مع العلم ان الزوار لا يستطيعون مشاهدة كل المواضيع المطروحة بالمنتدى


انضم إلى المنتدى ، فالأمر سريع وسهل

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

مختبر 8

3 مشترك

اذهب الى الأسفل

تثبيت مختبر 8

مُساهمة من طرف Basel Tamimi 25/4/2011, 12:26 pm

السلام عليكم
..

هاي اسئلة مختبر يوم الاثنين بس اللي كاتب نص الأسئلة يكتبها لأنو انا مش كاتبهاShocked
بس هيك فكرة السؤال



السؤال الاول: عرف مصفوفة من حجم 10 واسند لها قيم، ثم من خلال دالة اعكس قيم المصفوفة (دون استخدام مصفوفة اخرى) واطبع الناتج في دالة ثانية

الكود:

#include <iostream>
#define size 10
using namespace std;
void swap();
void prn();
int Num[size];
int main(){

   for (int i=0;i<size;i++)
cin>>Num[i];

swap();

cout<<endl;
system("pause");
}


void swap(){
   int temp;

for(int i=0;i<(size/2);i++)
{
temp=Num[i];
Num[i]=Num[size-1-i];
Num[size-1-i]=temp;}

prn();
}

void prn(){
cout<<"the arr is ";
for(int i=0;i<size;i++){
   cout<<Num[i]<<" ";}

}



السؤال الثاني:استخدم دالة مناسبة لحساب عدد حروف العلة في جملة يدخلها المستخدم


الكود:

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

void vowelCounter(string sentence);
int main(){
string sentence = "";

   cout<<"enter a sentence: ";
   getline(cin,sentence);

   vowelCounter(sentence);

cout<<endl;
system("pause");
}

void vowelCounter(string sentence){   
int voil=0;

for(int w=0; w < sentence.length() ;w++)
switch(sentence[w]){
   case 'a': case 'e': case 'o': case 'u': case 'i': voil++;break;   
}

cout<<"the number of voils= "<<voil;
}




السؤال الثالث: اكتب برنامج لفحص ما اذا كانت الكلمة المدخلة متماثلة حول الخانة الوسطى ام لا (مثل aammbbmmaa متماثل)

الكود:

#include <iostream>
#include <string>
#define size 100

using namespace std;

int swap(char sentence[size]);
char sentence[size],test[size];
int main(){

int decision;

   cout<<"type anything: ";   
   cin>>sentence;

   strcpy(test,sentence);

decision=swap(sentence);

if(decision==0)cout<<"palindrome ";
else cout<<"not palindrome ";

cout<<endl;
system("pause");
}


int swap(char sentence[size]){

   char temp;
   int size2,decision;

   size2=strlen(sentence);

for(int i=0;i<(size2/2);i++)
{
temp= sentence[i];
sentence[i]=sentence[size2-1-i];
sentence[size2-1-i]=temp;}


decision=strcmp(test,sentence);

return decision;

}


ازا في أي خطأ بالحل خبروني..

وازا في حلول تانية شاركونا

^___^


عدل سابقا من قبل Basel Tamimi في 27/4/2011, 1:16 pm عدل 1 مرات
Basel Tamimi
Basel Tamimi

عدد المساهمات : 44
تاريخ التسجيل : 09/03/2011
العمر : 32
الموقع : الخليل

https://is-it1.alafdal.net/

الرجوع الى أعلى الصفحة اذهب الى الأسفل

تثبيت رد: مختبر 8

مُساهمة من طرف anas mohtaseb 25/4/2011, 3:33 pm

مختبر 8 Z5745462

الحل تم بالمختبر
ما كان معي الفلاشة Laughing
anas mohtaseb
anas mohtaseb

عدد المساهمات : 29
تاريخ التسجيل : 08/03/2011
الموقع : https://www.facebook.com/anasmohtaseb

https://www.facebook.com/anasmohtaseb

الرجوع الى أعلى الصفحة اذهب الى الأسفل

تثبيت رد: مختبر 8

مُساهمة من طرف aya 25/4/2011, 4:12 pm

Basel Tamimi كتب:

السؤال الاول: read 10 integers into array A[10] and them do:
call afunction reserve to reserve the elements of the array .
call afunction preserve to print the elements of the new array.

الكود:

#include <iostream>
#define size 10
using namespace std;
void swap();
void prn();
int Num[size];
int main(){

   for (int i=0;i<size;i++)
cin>>Num[i];

swap();

cout<<endl;
system("pause");
}


void swap(){
   int temp;

for(int i=0;i<(size/2);i++)
{
temp=Num[i];
Num[i]=Num[size-1-i];
Num[size-1-i]=temp;}

prn();
}

void prn(){
cout<<"the arr is ";
for(int i=0;i<size;i++){
   cout<<Num[i]<<" ";}

}



السؤال الثاني:استخدم دالة مناسبة لحساب عدد حروف العلة في جملة يدخلها المستخدم


الكود:

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

void vowelCounter(string sentence);
int main(){
string sentence = "";

   cout<<"enter a sentence: ";
   getline(cin,sentence);

   vowelCounter(sentence);

cout<<endl;
system("pause");
}

void vowelCounter(string sentence){   
int voil=0;

for(int w=0; w < sentence.length() ;w++)
switch(sentence[w]){
   case 'a': case 'e': case 'o': case 'u': case 'i': voil++;break;   
}

cout<<"the number of voils= "<<voil;
}




السؤال الثالث: write aprogram to read astring and then calls afunction pal to check if the string is palindrome or not.


الكود:

#include <iostream>
#include <string>
#define size 100

using namespace std;

int swap(char sentence[size]);
char sentence[size],test[size];
int main(){

int decision;

   cout<<"type anything: ";   
   cin>>sentence;

   strcpy(test,sentence);

decision=swap(sentence);

if(decision==0)cout<<"palindrome ";
else cout<<"not palindrome ";

cout<<endl;
system("pause");
}


int swap(char sentence[size]){

   char temp;
   int size2,decision;

   size2=strlen(sentence);

for(int i=0;i<(size2/2);i++)
{
temp= sentence[i];
sentence[i]=sentence[size2-1-i];
sentence[size2-1-i]=temp;}


decision=strcmp(test,sentence);

return decision;

}
..
aya
aya

عدد المساهمات : 4
تاريخ التسجيل : 18/04/2011

الرجوع الى أعلى الصفحة اذهب الى الأسفل

تثبيت رد: مختبر 8

مُساهمة من طرف Basel Tamimi 25/4/2011, 5:12 pm

بسيطة يا انس بس المرة الجاي بتجيبها ^__*


وشكراً كتير آية ^__^

بالتوفيق للجميع بإمتحان بكرة Shocked
Basel Tamimi
Basel Tamimi

عدد المساهمات : 44
تاريخ التسجيل : 09/03/2011
العمر : 32
الموقع : الخليل

https://is-it1.alafdal.net/

الرجوع الى أعلى الصفحة اذهب الى الأسفل

الرجوع الى أعلى الصفحة

- مواضيع مماثلة

 
صلاحيات هذا المنتدى:
لاتستطيع الرد على المواضيع في هذا المنتدى