منتديات عالمي حلم

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

العالم المليئ بالأحلام

في منتديآت عالمي حلم تتحـقـق أحلامك

    ass nbkjbkjnkjn

    Admin
    Admin
    Admin


    عدد المساهمات : 413
    تاريخ التسجيل : 20/10/2010

    ass           nbkjbkjnkjn Empty ass nbkjbkjnkjn

    مُساهمة من طرف Admin الخميس أبريل 13, 2017 6:01 am

    الكود:
    /**********************************************************
    *   ID:   Write Your ID Here  ...      *
    *   Name: Somaia Ayman Mohammad Badawi     *
    *   Sec:  8                                  *
    **********************************************************/
    #include <iomanip>
    #include <iostream>
    #include <cmath>
    #include <math.h>
    #include <string>
     #include <fstream>
    using namespace std;
    const int ARRMAXSIZE = 100;
    الكود:
       string Problem12(string filename);
    الكود:
    /* Problem 1 */
    //For problem 1, use these two functions:
    //1. hours: the hours for which you want to calculate the sum
    //2. num:   number of grades that the user entered
    float sum(int hours[], int num)
    {
     float sum=0;
    الكود:
     for(int i=0;i<num;i++)
     {sum=sum+hours[i];}
     return sum;
    }
    //1. integerGrades the grades for each course after you turned it from character to integer format
    //2. hours the number of hours in each course
    float CalculateGPA(int integerGrades[], int hours[], int sum, int num)
    {
     float SumOfGrades=0,result;
      for(int i=0;i<num;i++)
     {SumOfGrades+=integerGrades[i]*hours[i];
     }
     result=SumOfGrades/sum;
    الكود:
     return  result;
    }
    الكود:
    //--------------------------------------------------------------------------------
    الكود:
    /* Problem 2 */
    //For problem 2, use this function:
    //1. arr: the array which contains your numbers
    //2. oldSize: the original size of the array, user input
    //3. newSize: the size of the array after removing
    void removal(int arr[], int oldSize, int& newSize)
    {int InstanceNUM;
    newSize=oldSize;
    cin>>InstanceNUM;
       for (int j=0;j<oldSize;j++)
        {if (arr[j]==InstanceNUM)
           {newSize--;
            for (int i=j;i<oldSize-1;i++)
               {arr[i]=arr[i+1];
    الكود:
               }
    الكود:
           }

    الكود:
        }
         for (int j=0;j<newSize;j++)
         {
             cout<<arr[j]<<setw(3);
         }
    }
    الكود:
    //--------------------------------------------------------------------------------
    الكود:
    /* Problem 3 */
    //For problem number 3 use the following functions.
    الكود:
    //1. arr: the array which contains your numbers
    //2. CSum: the 2D array that will hold the cumulative sum
    const int size = 16;//i changed my self :/ it was 10 before
    int Arr[size][size], CSum[size][size];
    الكود:
    //1. m: how many rows
    //2. n: how many columns
    //This function will read the array.
    void  inputArray(int m, int n)
    {cout<<"Enter the array: "<<endl;
            for (int i=0;i<m;i++)
            { for (int j=0;j<n;j++)
        {cin>>Arr[i][j]; }
             }
    }
    //1. m: how many rows
    //2. n: how many columns
    //this function will calculate the CSum array.
    void calc_Sum(int m, int n)
    {int CSumArray=0;
      for (int i=0;i<m;i++)
            { for (int j=0;j<n;j++)
        {CSumArray=CSumArray+Arr[i][j];
              Arr[i][j]=CSumArray;
                    }
             }
    }
    //1. m: how many rows
    //2. n: how many columns
    //This function will display the CSum array.
    void DisplayCumulative(int m, int n)
    {cout<<"The cumulative sum array is: "<<endl;
        for (int i=0;i<m;i++)
            { for (int j=0;j<n;j++)
             {cout<<Arr[i][j]<<"  "; }
    cout<<endl;
             }
    }
    الكود:

    //--------------------------------------------------------------------------------
    الكود:
    /* Problem 4 */
    //For problem number 4 use this function:
    //1. arr_2d: the 2D unsorted array
    //2. rows : rows number
    //3. cols : columns number
    void sorting_columns(int arr_2d[][ARRMAXSIZE], int rows, int cols)
    {  int MinNumber,iii,jjj,BoxNumber;
     int y,n,s,x;
    for(int i=0;i<5;i++)
    {
        for(int g=0;g<5;g++)
        {
            //cin>>arr[j][i];
    الكود:
            n=arr_2d[g][i];
          for(int j=g;j<5;j++)
          {if (n>=arr_2d[j][i])
           {
               n=arr_2d[j][i];
               s=j;
               y=i;
           }
    الكود:
          }
          x=arr_2d[g][i];
          arr_2d[g][i]=n;
          arr_2d[s][y]=x;
        }
    }
    الكود:
     
     
     
     
     
     
     cout<<"Array with sorted columns:"<<endl;
    الكود:

    }
    الكود:
    //--------------------------------------------------------------------------------
    الكود:
    /* Problem 5 */
    //For problem number 5 use the following functions.
    الكود:
    //1. arr: the 2D array
    //2. rows : rows number
    //3. cols : columns number
    //This function shall return the average float value.
    float calculateAvg(int arr[][10], int row, int col)
    { float sum=0, average5;
    for (int i = 0; i < row; i++)
    {  for (int j = 0; j < col; j++)
                      {sum=sum+arr[i][j];}
    الكود:
    }
    average5=sum/(row*col);
     return average5;
    }
    الكود:
    //1. arr: the 2D array
    //2. rows : rows number
    //3. cols : columns number
    //This function shall display the integers that are larger than or equal to the average.
    void displayAboveAverage(int arr[][10], int row, int col,float avg)
    {
     cout<<"The Average is "<< avg<<endl;
    cout<<"The numbers above or equal average are :";
     for (int i = 0; i < row; i++)
    {  for (int j = 0; j < col; j++)
                      {if (arr[i][j]>=avg)
     {cout<<arr[i][j]<<" ";}
     }
    الكود:
    }
     cout<<endl;
     
    }
    الكود:
    //--------------------------------------------------------------------------------
    الكود:
    /* Problem 6 */
    //For problem number 6 use this function:
    //1. N: the number to check
    bool CheckPerfectNumber (int N)
    {    bool perfect=true;
     int sum=0,p=1;
     while (p<N)
     { if (N%p==0)
     {sum=sum+p;}
     p++;
     }
     
     if (sum==N)
      return true;
     perfect=false;
     return false;
    }
    //--------------------------------------------------------------------------------
    الكود:
    /* Problem 7 */
    الكود:
    struct Subject {
    الكود:
     string SubjectName;
     int SubjectGrade;
    };
    الكود:
    struct Student {
    الكود:
     int StudentID;
     string StudentName;
     Subject subjects[6];
     float OverallGrade;
    };
    الكود:
    void CalculateOverAllGrade(Student StudentList[], int NumberOfStudents)
    { float sum=0,overall7;
     //cout<<"ID  Name  Overall Grade "<<endl;
     for (int i = 0; i < NumberOfStudents; i++)
     {
     for (int h = 0; h < 6; h++)
     {sum=sum+StudentList[i].subjects[h].SubjectGrade;
    الكود:
        }
     StudentList[i].OverallGrade=sum/6;
     sum=0;
     }
    الكود:
    }
    الكود:
    void CalculateSubjectAverageGrade(Student StudentList[], int NumberOfStudents)
    {
     float avggrade[6]={0};
     for (int i = 0; i < NumberOfStudents; i++)
     {
      for (int j = 0; j  < 6; j ++)
      {avggrade[j]=avggrade[j]+StudentList[i].subjects[j].SubjectGrade;
    الكود:
      }
    الكود:
     }
     cout<<"Subject Name     Average Grade"<<endl;
     cout<<"math1"<<"";



    الكود:

     cout<<'"'<<"****************************************************************" <<'"'<<endl;
    }
    الكود:
    //--------------------------------------------------------------------------------
    الكود:
    /* Problem 8 */
    //For problem number 8, use the following functions.
    //1. number: the number that you want to check whether it is Armstrong number or not
    bool IsArmstrong(int number)
    {   int arm[100],num=number,i=0,sum=0;
    while (num!=0)
    {sum=pow(num%10,3)+sum;
    num=num/10;
    i++;
    }
    if (sum==number)
     return true ;
    الكود:

     //Don't forget to remove this -1 and return the correct value!
     return false;
    }
    http://1.Start:  the first number in ther interval
    http://2.End: the second number in the interval
    void displayAllArmstrongNumbers(int Start, int End)
    {cout<<"Armstrong numbers between "<<Start<<" and "<<End<<" are: "<<endl;
     for (int i = Start; i <= End; i++)
     {if (IsArmstrong(i)==true)
       {cout<<i<<endl;}
    الكود:
     }
    }
    الكود:
    //--------------------------------------------------------------------------------
    الكود:
    /* Problem 9 */
    //For problem number 9, use this function:
    //1. arr :- the array that the user want to insert the element in
    //2. element :- the element that must be inserted in the array
    //3. index :- the index that the element will be inserted in.
    //This functions shall returns the plate number of the first car leaving
    int insert(int arr[], int element , int index,int size)//فيه حد نزود البارامتر الي في الاخر
    {     cout<<"OUTPUT:"<<endl;
     for (int i = size-1; i >index ; i--)
     {arr[i]=arr[i-1];
    الكود:

     }
     
     arr[index]=element;
    الكود:

     //Don't forget to remove this -1 and return the correct value!
     return 0;
    }
    الكود:
    //--------------------------------------------------------------------------------
    الكود:
    /* Problem 10 */
    //For problem number 10, use this function:
    //1. arr :- the 2Darray that the user want to crop
    //2. startRowRange,endRowRange the range for row
    //3. startColRange,endColRange the range for column
    //This functions shall construct a new 2D array to retain only elements within a specified range and display it.
    void crop2DArray(int arr[5][5], int startRowRange, int endRowRange, int startColRange, float endColRange)
    { int newrow=0,newcol=0;
     for (int j = startRowRange; j <= endRowRange; j++)
     { newcol=0;
      for (int i = startColRange; i <= endColRange; i++)
      {arr[newrow][newcol] =arr[j][i];
            newcol++;
       }
      newrow++;
     }
     
    }
    الكود:
    //--------------------------------------------------------------------------------
    الكود:
    /* Problem 11 */
    //For problem number 11, use the following:
    //const int size = 16;
    struct TeamScore
    {
     string TeamName;
       int Pointscollected ;
    الكود:
    } AllTeams[size];
    الكود:
    void inputTeams()
    {for (int i = 0; i < 16; i++)
     {cout<<"Enter Team name for team number  "<<i+1<<": ";
      cin>>AllTeams[i].TeamName;
      cout<<"Enter Points collected for team number  "<<i+1<<": ";
     cin>>AllTeams[i].Pointscollected;
    الكود:
     }
    }
    void sort()
    {int BOX,MIN11,SaveNumber;
    string savestring;
     for (int i = 0; i < 16; i++)
     { MIN11=AllTeams[i].Pointscollected;
      for (int j = i; j < 16; j++)
      { if (AllTeams[j].Pointscollected<=MIN11)
           {MIN11=AllTeams[j].Pointscollected;
            BOX=j;}
    الكود:
      }
     SaveNumber= AllTeams[i].Pointscollected;
     savestring=AllTeams[i].TeamName;
     AllTeams[i].TeamName=AllTeams[BOX].TeamName;
     AllTeams[BOX].TeamName=savestring;
     AllTeams[i].Pointscollected=MIN11;
     AllTeams[BOX].Pointscollected=SaveNumber;
     }

    الكود:
    }
    void displayFinalFour()
    {cout<<"Final Four Teams "<<endl;
     for (int i = 15; i >= 12  ; i--)
     {  cout<<AllTeams[i].TeamName<<" with ";
      cout<<AllTeams[i].Pointscollected<<" points "<<endl;
     }
    الكود:

    }
    الكود:
    //--------------------------------------------------------------------------------
    الكود:
    /* Problem 12 */
    //For problem number 12, use this:
    void charFreq(string fileName)
    {
    }
    الكود:
    //--------------------------------------------------------------------------------
    الكود:
    int main()
    {
    الكود:
     string line;
      ifstream myfile ("so.txt");
      if (myfile.is_open())
      {
        while ( getline (myfile,line) )
        {
          cout << line << '\n';
        }
        myfile.close();
      }
    الكود:
      else cout << "Unable to open file";
    الكود:
     
     return 0;
    }


    /**********************************************************
    *   ID:   Write Your ID Here  ...      *
    *   Name: Somaia Ayman Mohammad Badawi     *
    *   Sec:  8                                  *
    **********************************************************/
    #include <iomanip>
    #include <iostream>
    #include <cmath>
    #include <math.h>
    #include <string>
     #include <fstream>
    using namespace std;
    const int ARRMAXSIZE = 100;
       string Problem12(string filename);
    /* Problem 1 */
    //For problem 1, use these two functions:
    //1. hours: the hours for which you want to calculate the sum
    //2. num:   number of grades that the user entered
    float sum(int hours[], int num)
    {
     float sum=0;
     for(int i=0;i<num;i++)
     {sum=sum+hours[i];}
     return sum;
    }
    //1. integerGrades the grades for each course after you turned it from character to integer format
    //2. hours the number of hours in each course
    float CalculateGPA(int integerGrades[], int hours[], int sum, int num)
    {
     float SumOfGrades=0,result;
      for(int i=0;i<num;i++)
     {SumOfGrades+=integerGrades[i]*hours[i];
     }
     result=SumOfGrades/sum;
     return  result;
    }
    //--------------------------------------------------------------------------------
    /* Problem 2 */
    //For problem 2, use this function:
    //1. arr: the array which contains your numbers
    //2. oldSize: the original size of the array, user input
    //3. newSize: the size of the array after removing
    void removal(int arr[], int oldSize, int& newSize)
    {int InstanceNUM;
    newSize=oldSize;
    cin>>InstanceNUM;
       for (int j=0;j<oldSize;j++)
        {if (arr[j]==InstanceNUM)
           {newSize--;
            for (int i=j;i<oldSize-1;i++)
               {arr[i]=arr[i+1];
               }
           }

        }
         for (int j=0;j<newSize;j++)
         {
             cout<<arr[j]<<setw(3);
         }
    }
    //--------------------------------------------------------------------------------
    /* Problem 3 */
    //For problem number 3 use the following functions.
    //1. arr: the array which contains your numbers
    //2. CSum: the 2D array that will hold the cumulative sum
    const int size = 16;//i changed my self :/ it was 10 before
    int Arr[size][size], CSum[size][size];
    //1. m: how many rows
    //2. n: how many columns
    //This function will read the array.
    void  inputArray(int m, int n)
    {cout<<"Enter the array: "<<endl;
            for (int i=0;i<m;i++)
            { for (int j=0;j<n;j++)
        {cin>>Arr[i][j]; }
             }
    }
    //1. m: how many rows
    //2. n: how many columns
    //this function will calculate the CSum array.
    void calc_Sum(int m, int n)
    {int CSumArray=0;
      for (int i=0;i<m;i++)
            { for (int j=0;j<n;j++)
        {CSumArray=CSumArray+Arr[i][j];
              Arr[i][j]=CSumArray;
                    }
             }
    }
    //1. m: how many rows
    //2. n: how many columns
    //This function will display the CSum array.
    void DisplayCumulative(int m, int n)
    {cout<<"The cumulative sum array is: "<<endl;
        for (int i=0;i<m;i++)
            { for (int j=0;j<n;j++)
             {cout<<Arr[i][j]<<"  "; }
    cout<<endl;
             }
    }

    //--------------------------------------------------------------------------------
    /* Problem 4 */
    //For problem number 4 use this function:
    //1. arr_2d: the 2D unsorted array
    //2. rows : rows number
    //3. cols : columns number
    void sorting_columns(int arr_2d[][ARRMAXSIZE], int rows, int cols)
    {  int MinNumber,iii,jjj,BoxNumber;
     int y,n,s,x;
    for(int i=0;i<5;i++)
    {
        for(int g=0;g<5;g++)
        {
            //cin>>arr[j][i];
            n=arr_2d[g][i];
          for(int j=g;j<5;j++)
          {if (n>=arr_2d[j][i])
           {
               n=arr_2d[j][i];
               s=j;
               y=i;
           }
          }
          x=arr_2d[g][i];
          arr_2d[g][i]=n;
          arr_2d[s][y]=x;
        }
    }
     
     
     
     
     
     
     cout<<"Array with sorted columns:"<<endl;

    }
    //--------------------------------------------------------------------------------
    /* Problem 5 */
    //For problem number 5 use the following functions.
    //1. arr: the 2D array
    //2. rows : rows number
    //3. cols : columns number
    //This function shall return the average float value.
    float calculateAvg(int arr[][10], int row, int col)
    { float sum=0, average5;
    for (int i = 0; i < row; i++)
    {  for (int j = 0; j < col; j++)
                      {sum=sum+arr[i][j];}
    }
    average5=sum/(row*col);
     return average5;
    }
    //1. arr: the 2D array
    //2. rows : rows number
    //3. cols : columns number
    //This function shall display the integers that are larger than or equal to the average.
    void displayAboveAverage(int arr[][10], int row, int col,float avg)
    {
     cout<<"The Average is "<< avg<<endl;
    cout<<"The numbers above or equal average are :";
     for (int i = 0; i < row; i++)
    {  for (int j = 0; j < col; j++)
                      {if (arr[i][j]>=avg)
     {cout<<arr[i][j]<<" ";}
     }
    }
     cout<<endl;
     
    }
    //--------------------------------------------------------------------------------
    /* Problem 6 */
    //For problem number 6 use this function:
    //1. N: the number to check
    bool CheckPerfectNumber (int N)
    {    bool perfect=true;
     int sum=0,p=1;
     while (p<N)
     { if (N%p==0)
     {sum=sum+p;}
     p++;
     }
     
     if (sum==N)
      return true;
     perfect=false;
     return false;
    }
    //--------------------------------------------------------------------------------
    /* Problem 7 */
    struct Subject {
     string SubjectName;
     int SubjectGrade;
    };
    struct Student {
     int StudentID;
     string StudentName;
     Subject subjects[6];
     float OverallGrade;
    };
    void CalculateOverAllGrade(Student StudentList[], int NumberOfStudents)
    { float sum=0,overall7;
     //cout<<"ID  Name  Overall Grade "<<endl;
     for (int i = 0; i < NumberOfStudents; i++)
     {
     for (int h = 0; h < 6; h++)
     {sum=sum+StudentList[i].subjects[h].SubjectGrade;
        }
     StudentList[i].OverallGrade=sum/6;
     sum=0;
     }
    }
    void CalculateSubjectAverageGrade(Student StudentList[], int NumberOfStudents)
    {
     float avggrade[6]={0};
     for (int i = 0; i < NumberOfStudents; i++)
     {
      for (int j = 0; j  < 6; j ++)
      {avggrade[j]=avggrade[j]+StudentList[i].subjects[j].SubjectGrade;
      }
     }
     cout<<"Subject Name     Average Grade"<<endl;
     cout<<"math1"<<"";




     cout<<'"'<<"****************************************************************" <<'"'<<endl;
    }
    //--------------------------------------------------------------------------------
    /* Problem 8 */
    //For problem number 8, use the following functions.
    //1. number: the number that you want to check whether it is Armstrong number or not
    bool IsArmstrong(int number)
    {   int arm[100],num=number,i=0,sum=0;
    while (num!=0)
    {sum=pow(num%10,3)+sum;
    num=num/10;
    i++;
    }
    if (sum==number)
     return true ;

     //Don't forget to remove this -1 and return the correct value!
     return false;
    }
    http://1.Start:  the first number in ther interval
    http://2.End: the second number in the interval
    void displayAllArmstrongNumbers(int Start, int End)
    {cout<<"Armstrong numbers between "<<Start<<" and "<<End<<" are: "<<endl;
     for (int i = Start; i <= End; i++)
     {if (IsArmstrong(i)==true)
       {cout<<i<<endl;}
     }
    }
    //--------------------------------------------------------------------------------
    /* Problem 9 */
    //For problem number 9, use this function:
    //1. arr :- the array that the user want to insert the element in
    //2. element :- the element that must be inserted in the array
    //3. index :- the index that the element will be inserted in.
    //This functions shall returns the plate number of the first car leaving
    int insert(int arr[], int element , int index,int size)//فيه حد نزود البارامتر الي في الاخر
    {     cout<<"OUTPUT:"<<endl;
     for (int i = size-1; i >index ; i--)
     {arr[i]=arr[i-1];

     }
     
     arr[index]=element;

     //Don't forget to remove this -1 and return the correct value!
     return 0;
    }
    //--------------------------------------------------------------------------------
    /* Problem 10 */
    //For problem number 10, use this function:
    //1. arr :- the 2Darray that the user want to crop
    //2. startRowRange,endRowRange the range for row
    //3. startColRange,endColRange the range for column
    //This functions shall construct a new 2D array to retain only elements within a specified range and display it.
    void crop2DArray(int arr[5][5], int startRowRange, int endRowRange, int startColRange, float endColRange)
    { int newrow=0,newcol=0;
     for (int j = startRowRange; j <= endRowRange; j++)
     { newcol=0;
      for (int i = startColRange; i <= endColRange; i++)
      {arr[newrow][newcol] =arr[j][i];
            newcol++;
       }
      newrow++;
     }
     
    }
    //--------------------------------------------------------------------------------
    /* Problem 11 */
    //For problem number 11, use the following:
    //const int size = 16;
    struct TeamScore
    {
     string TeamName;
       int Pointscollected ;
    } AllTeams[size];
    void inputTeams()
    {for (int i = 0; i < 16; i++)
     {cout<<"Enter Team name for team number  "<<i+1<<": ";
      cin>>AllTeams[i].TeamName;
      cout<<"Enter Points collected for team number  "<<i+1<<": ";
     cin>>AllTeams[i].Pointscollected;
     }
    }
    void sort()
    {int BOX,MIN11,SaveNumber;
    string savestring;
     for (int i = 0; i < 16; i++)
     { MIN11=AllTeams[i].Pointscollected;
      for (int j = i; j < 16; j++)
      { if (AllTeams[j].Pointscollected<=MIN11)
           {MIN11=AllTeams[j].Pointscollected;
            BOX=j;}
      }
     SaveNumber= AllTeams[i].Pointscollected;
     savestring=AllTeams[i].TeamName;
     AllTeams[i].TeamName=AllTeams[BOX].TeamName;
     AllTeams[BOX].TeamName=savestring;
     AllTeams[i].Pointscollected=MIN11;
     AllTeams[BOX].Pointscollected=SaveNumber;
     }

    }
    void displayFinalFour()
    {cout<<"Final Four Teams "<<endl;
     for (int i = 15; i >= 12  ; i--)
     {  cout<<AllTeams[i].TeamName<<" with ";
      cout<<AllTeams[i].Pointscollected<<" points "<<endl;
     }

    }
    //--------------------------------------------------------------------------------
    /* Problem 12 */
    //For problem number 12, use this:
    void charFreq(string fileName)
    {
    }
    //--------------------------------------------------------------------------------
    int main()
    {
     string line;
      ifstream myfile ("so.txt");
      if (myfile.is_open())
      {
        while ( getline (myfile,line) )
        {
          cout << line << '\n';
        }
        myfile.close();
      }
      else cout << "Unable to open file";
     
     return 0;
    }

      الوقت/التاريخ الآن هو الجمعة نوفمبر 22, 2024 8:36 am