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


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

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

Programming Assignment الحل الثاني

4 مشترك

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

تثبيت Programming Assignment الحل الثاني

مُساهمة من طرف Basel Tamimi 27/4/2011, 2:04 pm

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

هادا حلي لوظيفة البرمجة ..
اي سؤال على طريقتي بالحل مرحب فيه

واي ملاحظة او تعديل بكون شاكر للمساهمين معنا




السؤال الأول:
Write a program to do the following:

$ declare the two dimension array NUM of five rows and five columns
$ fill in the array elements with values as follows
Hint : build and call a function power
$ call a function printing(…) to print the elements of the array on the screen
$ print the sum of the elements in a selected column m


الكود:
//++++++++++++++++++++++++++++++++++++++++++++++
// Name: Basel Younes AlTamimi  ~||~  ID: 100005
//++++++++++++++++++++++++++++++++++++++++++++++

//Q1))..
#include <iostream>
#define row 5
#define column 5
using namespace std;

int power(int n,int y);
void PrintNUM();
void PrintSum();
int NUM [row][column] ;
int main (){
    int temp ;

    for(int i=1 ; i<row ; i++){
        NUM[i-1][0] = 1;
        for(int j=1 ; j<=column ; j++)
            NUM[i-1][j] = power(i , j);
    }
   
    //for printing
    PrintNUM();
    cout<<"\n\n";

    //column summation
    PrintSum();

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

int power(int n , int y){
    int pwr = 1 , sum = 0;
    for(int i=0 ; i< y ; i++){
    pwr = pwr * n;}
    return pwr;
}



void PrintNUM()
{int temp;
cout<<"the power array as the following:\n"
        <<"---------------------------------\n"
        <<"0  1  2  3  4  ....column numbers....\n"
        <<"^^^^^^^^^^^^^^^^^\n";

    for(int i=0 ; i<(row-1) ; i++){
        for(int j=0 ; j<column ; j++){
           
                if(NUM[i][j] < 10)       
                cout<< NUM[i][j] <<"  ";
                else       
            cout<< NUM[i][j] <<"  ";}
    cout<<endl;}   
}



void PrintSum(){
    int SelectedColumn;

    for(int j=0 ; j<column ; j++)
        NUM[4][j] = 0;

    //column summation
    cout<<"enter the column number to find its summation: ";
    cin>> SelectedColumn;

    if(SelectedColumn>4 || SelectedColumn<0)
        cout<<"error!!\n";

    else{
    for(int i=0 ; i<(row-1) ; i++){
        NUM[row-1][SelectedColumn] = NUM[row-1][SelectedColumn] + NUM[i][SelectedColumn];
        }
    cout<< "the summation of the column is "<<NUM[4][SelectedColumn];
    }
}


عدل سابقا من قبل Basel Tamimi في 6/5/2011, 5:26 am عدل 1 مرات
Basel Tamimi
Basel Tamimi

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

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

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

تثبيت تابع للحل السابق ...

مُساهمة من طرف Basel Tamimi 27/4/2011, 2:22 pm

السؤال الخامس:

Write a program that displays the factorial of (N) numbers using fact_fun(…) that accepts the number and return the result to main.

الكود:

//++++++++++++++++++++++++++++++++++++++++++++++
// Name: Basel Younes AlTamimi  ~||~  ID: 100005
//++++++++++++++++++++++++++++++++++++++++++++++

//Q5))..
#include <iostream>
double fact_fun(int n);
using namespace std;
int main (){
   int n;
   double fact;
   cout<<"enter a number n >>( n <170 )<< to display its factorial \n"
      <<"to exit enter -1\n"
      <<"-------\n";
   cin>>n;
   cout<<endl;
   while(n!=-1){
      if(n==0)
         {cout<<"the result is: "<<1<<endl
             <<"--------------\n";}
      else if (n<0)
         cout<<"the entered number should be 0 or greater\n";
      else{
   fact=fact_fun(n);
   cout<<"the result is: "<<fact<<endl
      <<"--------------\n";}
   cout<<endl<<"enter another number: ";
   cin>>n;
   }

return 0;
}

double fact_fun(int n){
   double fact=n;

   for(int i=n-1;i>0;i--)
      fact=fact*i;
return fact;
}


السؤال السادس:

Write a program that calls a function fib( n) in which the function receives (n) and prints the first (n) terms of the Fibonacci series.
Example if n=7
The output: 1 1 2 3 5 8 13

الكود:

//++++++++++++++++++++++++++++++++++++++++++++++
// Name: Basel Younes AlTamimi  ~||~  ID: 100005
//++++++++++++++++++++++++++++++++++++++++++++++

//Q6))..
#include <iostream>
void fibon(int n);
using namespace std;
int main (){
   int n;

   cout<<"this program to print the first (n) terms of the Fibonacci series\n\n"
      <<"enter a number:\n"
      <<"---------------\n";
   cin>>n;
   cout<<endl<<"The terms: ";
   fibon(n);

   cout<<"\n\n";
system ("pause");
return 0;
}


void fibon(int n){
int fib[100];
for(int i=0;i<n;i++){
   if (i<2)
      fib [i]=1;
   else
   fib[i]=fib[i-1]+fib[i-2];
}

for(int i=0;i<n;i++)
   cout<<fib[i]<<" ";
}
ع فكرة: لما اجا هادا السؤال بالامتحان حليتو بطريقة تانية Shocked


السؤال السابع:

Write a program that calculates how many digits in an entered number n.

الكود:

//++++++++++++++++++++++++++++++++++++++++++++++
// Name: Basel Younes AlTamimi  ~||~  ID: 100005
//++++++++++++++++++++++++++++++++++++++++++++++

//Q7))..
#include <iostream>
double count(double n);
using namespace std;
int main (){
   double n,total;
   cout<<"This program calculates how many digits in an entered number.\n\n"
      <<"enter a number: \n"
      <<"---------------\n";
   cin>>n;
   total=count(n);
   cout<<"\nNumber of digits= "<<total;
   cout<<"\n\n";
system ("pause");
return 0;
}


double count(double n){
   double s=0;
for(double i=n;i>=1;i/=10)
   s++;
return s;
}


السؤال الثامن:

Write a program that checks a palindrome property for entered numbers, the number of digits is unknown. You can read the palindrome from either side
Example: 12321 is palindrome , 221122 is palindrome , 12345 is not

الكود:

//++++++++++++++++++++++++++++++++++++++++++++++
// Name: Basel Younes AlTamimi  ~||~  ID: 100005
//++++++++++++++++++++++++++++++++++++++++++++++

//Q8))..
#include <iostream>
void count(int n);
void check(int n,int size);
using namespace std;
int main (){
   int n;

   cout<<"This program checks a palindrome property for entered numbers\n"
      <<"the enterd number would be +ve and has less than 10 digits\n\n"
      <<"enter number: \n"
      <<"-------------\n";
   cin>>n;
   if (n<=999999999 && n>=0)
   count(n);

   else cout<<"your input equil (-) or has a large number of digits!!\n";
   cout<<endl;
system ("pause");
return 0;
}


void count(int n){
   int size=0;
for(int i=n;i>=1;i/=10)
   size++;

check(n, size);

}

void check(int n,int size){
   int origin=n;
int num[100],disision=1;
int i,j;
for(int i=0;i<size;i++){
   num[i]=n%10;
   n/=10;}

for(i=0,j=size-1 ;i<=j,j>=i; i++,j--)
   if (num[i]!=num[j]){
      disision=0;
      break;}

if (disision==1) cout<<"\nThe "<<origin<<" is Palindrome ";
else cout<<"\nThe "<<origin<<" is NOT palindrome ";
cout<<endl;
}
حلي بالسؤال الأخير معقد كتيير
مش عارف شو كان خاطر ع بالي لما حليتو ^__^
!!!!
lol!

.. على كل حل أنس اسهل



وبالختام
هاذا ما لدينا ..
وشكراً

^__^
Basel Tamimi
Basel Tamimi

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

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

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

تثبيت رد: Programming Assignment الحل الثاني

مُساهمة من طرف Basel Tamimi 27/4/2011, 2:27 pm

للتحميل المباشر:

من المرفقات >>>



المرفقات
Programming Assignment  الحل الثاني Attachment
Basel Tamimi III.zip لا تتوفر على صلاحيات كافية لتحميل هذه المرفقات.(13 Ko) عدد مرات التنزيل 8
Basel Tamimi
Basel Tamimi

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

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

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

تثبيت رد: Programming Assignment الحل الثاني

مُساهمة من طرف Admin 27/4/2011, 3:00 pm

Programming Assignment  الحل الثاني Z5745462

Admin
Admin

عدد المساهمات : 2
تاريخ التسجيل : 08/03/2011

https://is-it1.alafdal.net

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

تثبيت رد: Programming Assignment الحل الثاني

مُساهمة من طرف Basel Tamimi 27/4/2011, 6:21 pm

Welcome

Very Happy Very Happy
Basel Tamimi
Basel Tamimi

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

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

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

تثبيت رد: Programming Assignment الحل الثاني

مُساهمة من طرف hana 1/5/2011, 8:50 pm

شكرا كتير على مساهمتكم انت والاخ انس
بس المشكله انه نعرف نحلهم لما يجو بالامتحان

hana

عدد المساهمات : 2
تاريخ التسجيل : 09/03/2011
العمر : 35

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

تثبيت رد: Programming Assignment الحل الثاني

مُساهمة من طرف anas mohtaseb 1/5/2011, 8:58 pm

hana كتب:شكرا كتير على مساهمتكم انت والاخ انس
حياكم الله

hana كتب:بس المشكله انه نعرف نحلهم لما يجو بالامتحان
مش صعبات بس بدهم شوية تركيز
على كل حال جاي اضرابات كتير بنتسلى عليهم
anas mohtaseb
anas mohtaseb

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

https://www.facebook.com/anasmohtaseb

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

تثبيت رد: Programming Assignment الحل الثاني

مُساهمة من طرف Basel Tamimi 2/5/2011, 7:58 am

hana كتب:شكرا كتير على مساهمتكم انت والاخ انس
بس المشكله انه نعرف نحلهم لما يجو بالامتحان

العفو ..

وعلى سيرت الامتحان
كل ما تحلي اسئلة اكتر بتصير الفكرة تخطر ع بالك اسرع وبالامتحان ما بتتغلبي
ويمكن تصدف ويجي نفس السؤال اللي حليتيه بالامتحان !!

Basel Tamimi
Basel Tamimi

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

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

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

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

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

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