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

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

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

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

اوكي يسلمو زبط معي و طلعلي الاوت بوت
 
مشكوور عزيزي :blushing: :RpS_love: :RpS_lol:

سويت قيت لاين انا قبل بس ما صار ما ادري ليش :tongue343:



PHP:
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int main()
{
    string str;
    int min=100;
    ifstream in;in.open("name.txt");
    ofstream out;out.open("length.txt");
    if (!in){cout<<"Erorr no file";return 1;}
    while(!in.eof())
    {
        getline(in,str);
        out<<str.length()<<endl;
        if (str.length()<min)min=str.length();
    }
    cout<<"Maimum name size : "<<min<<endl;
    system("pause");
    return 0;
}

* تعديل على كود Noise ... مجرد إضافة getline
أمّا بالنسبة إلى الـ Spaces فبيطول الحل إذا بغينا نحذف الـ Spaces

و بالتوفيق جميعًا :smile2:
​
 
مشكوور عزيزي
سويت قيت لاين انا قبل بس ما صار ما ادري ليش
هههههههه :nosweat: :smile2: ...

يمكن ما خليت قوسين
أو خليّت ";" بدل ","
او حتى كتبت "cin" بدل الـ"in" (أسم دالة الـ input)
​
 
بس اخر سؤال ... كيف بدي اتأكد انو وصل الاسايمنت و اي فايلات االي لازم ابعتها؟؟
 
كود:
#include<iostream>
using namespace std;
void computeAverage(double arr[],double x, int size,double avg,double sum)
{
    avg=sum\size*1.0;
    cout<<"the avareg ="<<avg<<endl;
}
void displayAboveAverage(double arr[],double avg,int size)
{
    double indexavg;
    for (int i=0;i<size;i++)
        if(arr[i]>avg )
        {
            indexavg=avg;
        }
}
void countGrade(double oldvalue,double newvalue,double arr1[],double size1)
{
    for (int i=0;i<size;i++)
        if(arr1[i]>avg)
        {
            oldvalue=i;
            newvalue=arr1[i];
        }
}


void main ()
{
    double q1,q2,q3,q4,q5,q6,q7,q8,q9,q10, avg;
    long stid;
    string name;
    cout<<"enter student ID :"<<stid<<endl;
    cin>>stid;
    cout<<"enter student name :"<<name<<endl;
    cin>>name;
    cout<<"enter quiz grades:"<<endl;
    cin>>q1>>q2>>q3>>q4>>q5>>q6>>q7>>q8>>q9>>q10;
}



هاي بارت 2 :/ :( يطلع ايروورز ...!

اممم لاحظت عندش اغلاط واجد فأني بحاول اشرح لش على الي اقدر عليه
اول فانكشن

كود:
void computeAverage(double arr[],double x, int size,double avg,double sum)
{
    avg=sum\size*1.0;
    cout<<"the avareg ="<<avg<<endl;
مطلوب في السؤال :
1. A function named computeAverage that takes as parameters: an array of double and the array size. The function should calculate and return the average of the double numbers in the array.
يعني ال parameters لازم نحط بس الأري و السايز و غير جدي هو كاتب في السؤال return يعني لازم ترجع قيمة ال average و ماتكون الفانكشن void يعني:

كود:
double computeAverage(double arr[], int size)
ثاني شي احنا لازم نحسب كل رقم في الاري فلازم نستخدم فور لوب
ثاني فانكشن :

كود:
void displayAboveAverage(double arr[],double avg,int size)
{
    double indexavg;
    for (int i=0;i<size;i++)
        if(arr[i]>avg )
        {
            indexavg=avg;
        }
}
نفس الي قلته فوق بخصوص ال parameters
كود:
void displayAboveAverage(double arr[],int size)
و في السؤال طالب انسوي كولينق حق القيمة مالت ال average الي طلعناها في الفانكشن الاولى فإحنا لازم انضيف هالسطر في البداية
كود:
void displayAboveAverage(double arr[],int size)
{
;double avg
(avg=computeAverage( arr, size
    for (int i=0;i<size;i++)
        if(arr[i]>avg )
        {
           cout<<arr[i];
        }
}
و ماليه داعي الـ indexavg
الفانكشن الثالثة
اممم بالنسبة للكوندشن مالش " الشرط " مادري ليش حطيتينه جدي او وش كان قصدش
بس عدلته لش و ضفت سطرين في النهاية حق يطبع الاري بعد التعديل

كود:
void countGrade(double oldvalue,double newvalue,double arr1[],double size1){
    for (int i=0;i<size;i++)
        if(arr1[i]==oldvalue)
            newvalue=arr1[i];
{
for (int j=0;j<size;j++)
cout<<arr1[j]<<" ";}
}

و في المين ماسويتين كولينق حق ولا فانكشن لازم تسوين كولينق حقهم و المتغيرات q1 , q2,q3,etc ماليهم داعي
ملاحظة : اتأكدي من الكودات لأن على السريع كتبت الرد ماجربتهم
بالتوفيق
:smile2:
 
بس اخر سؤال ... كيف بدي اتأكد انو وصل الاسايمنت و اي فايلات االي لازم ابعتها؟؟

ملف "
cpp. " اللي فيه البرنامج

بعد الإرفاق و من داخل البلاك بورد
My Grades < Tools

المفروض يطلع جذي


XfScS.jpg
 
سلام شعب ,, ابي احد حليو وجميل يشرح لينه ال selection sort :whistling: ,, اني حفظت الكود بس ابي استوعبه
HTML:
#include<iostream>
using namespace std;
int main()
{
	int list[]={1,8,9,7,7,10,58,5,0};
	int temp,min=list[0];
	for (int i=0;i<9-1;i++)
	{
		min=i;
		for (int j=i+1;j<9;j++)
		{
			if (list[j]<list[min])
				min=j;
				temp=list[min];
				list[min]=list[i];
				list[i]=temp;
		}
	}
	for (int k=0;k<9;k++)
		cout<<list[k]<<" ";
	cout<<endl;
 
	return 0;
}
 
[TABLE="align: right"]
[TR]
[TD][/TD]
[/TR]
[/TABLE]

Part#1: Lab Exercise

Write a C++ program that includes the following functions:

1. A function named sortList that takes as parameters: an array of double and the array size. The function should sort the numbers in a descending order. Use selection sort algorithm.

2. A function named readList that takes as parameters: an array of double and the array size. The function should prompt the user to input the array data.

3. A function named printList that takes as parameters: an array of double and the array size. The function should display the elements of the array.

4. A function named print topFive that takes as parameters: an array of double and the array size. The function should print the largest five numbers in the array. Hint: you have to sort the array first.


Write a main program that prompts the user to enter his ID, name and 10 double numbers representing his quiz grades of ITCS104. Using the above functions, the program should generate a report as follow:


[TABLE="align: center"]
[TR]
[TD]Sample Input/Output:[/TD]
[/TR]
[TR]
[TD]Enter Student ID: 20081234
Enter Student Name: Student1
Enter quiz grades: 1.5 2.5 6.5 4.5 10 9 8 7 3.5 5.5

Report
ID: 20081234
Name: Student1
Grades (descending): 10 9 8 7 6.5 5.5 4.5 3.5 2.5 1.5
Top 5 grades: 10 9 8 7 6.5
[/TD]
[/TR]
[/TABLE]







Part#2: Home Assignment

Complete the previous exercise to include the following functions:

1. A function named computeAverage that takes as parameters: an array of double and the array size. The function should calculate and return the average of the double numbers in the array.

2. A function named displayAboveAverage that takes as parameters: an array of double and the array size. The function should display the numbers in the array that are above the average. Hint: call computeAverage to find the average of the numbers.

3. A function named countGrade that takes as parameters: an array of double, the array size, a double value (oldValue), and a double value (newValue). The function should replace each occurrence of the oldValue by the newValue.

Write a main program to test your functions.




ممكن فقط شرح طريقة السؤال؟؟!!

1=>

كود:
#include <iostream>
#include <string>
using namespace std;
void sortlist (double x[],int y)
{
    double z;
    for (int i=0;i<y;i++)
    {
        for (int j=i+1;j<y;j++)
        {
        if (x[i]<x[j])
        {
            z=x[i];
            x[i]=x[j];
            x[j]=z;
        }
        }
    }
}
void readList (double x[],int y)
{
     for(int i=0;i<y;i++)
     cin>>x[i];
}
void printList (double x[],int y)
{
     for(int i=0;i<y;i++)
     cout<<x[i]<<" ";
}
void printopFive (double x[],int y)
{
    double z;
    for (int i=0;i<y;i++)
    {
        for (int j=i+1;j<y;j++)
        {
        if (x[i]<x[j])
        {
            z=x[i];
            x[i]=x[j];
            x[j]=z;
        }
        }
    }
    for(int i=0;i<5;i++)
    cout<<x[i]<<" ";
}
     
int main()
{
    double quiz[10];
    int id;
    string name;
    cout<<"Enter Student ID: ";
    cin>>id;
    cout<<"Enter Student Name: ";
    cin>>name;
    cout<<"Enter quiz grades: ";
    readList(quiz,10);
    cout<<"\n\nReport\nID: "<<id<<"\nName: "<<name<<endl;
    cout<<"Grades (descending): ";
    sortlist(quiz,10);
    printList(quiz,10);
    cout<<"\nTop 5 grades: ";
    printopFive(quiz,10);
    cout<<endl;
    system("pause");
    return 0;
}

2=>

كود:
#include<iostream>
using namespace std;
double computeAverage (double arr[],int x)
{
    double sum=0;
    for(int i=0;i<x;i++)
    sum+=arr[i];
    return sum;
}
void displayAboveAverage (double arr[],int x)
{
    double avr=computeAverage(arr,x);
    for (int i=0;i<x;i++)
    if (arr[i]>x)cout<<arr[i]<<" ";
}
void countGrade(double arr[],double x,double oldv,double newv)
{
    for (int i=0;i<x;i++)
        if(arr[i]==oldv)arr[i]=newv;
}
int main ()
{
    double arr[10],oldv,newv;
    cout<<"enter quiz grades:"<<endl;
    for (int i=0;i<10;i++)
    cin>>arr[i];
    cout<<"Avrage: "<<computeAverage(arr,10)<<endl;
    cout<<"Abouve average: ";
    displayAboveAverage(arr,10);
    cout<<"\nEnter oldv & newv: ";
    cin>>oldv>>newv;
    cout<<"\nQuiz grades after change: ";
    countGrade(arr,10,oldv,newv);
    for (int i=0;i<x;i++)cout<<arr[i]<<" ";
    cout<<endl;
    system("pause");
    return 0;
}
 
PART A
Write a function named outputarr that output the elements of an integer array.
PART B
Write a function named readarr that reads the elements of an integer array.
PART C
Write a function named
minPosition that takes an array of integers intList, and the
index of the first element in the array (start), and the size of the array. The function should return the Position (Location) of the
minimum value in the array (a number between start and size).
For example, if the following array intList :

[TD="width: 10%, bgcolor: #ffffff"] 44
[/TD]
[TD="width: 10%, bgcolor: #ffffff"] 9
[/TD]
[TD="width: 10%, bgcolor: #ffffff"] 7
[/TD]
[TD="width: 10%, bgcolor: #ffffff"] 14
[/TD]
[TD="width: 10%, bgcolor: #ffffff"] 17
[/TD]
[TD="width: 10%, bgcolor: #ffffff"] 12
[/TD]
[TD="width: 10%, bgcolor: #ffffff"] 15
[/TD]
[TD="width: 10%, bgcolor: #ffffff"] 3
[/TD]
[TD="width: 10%, bgcolor: #ffffff"] 6
[/TD]
[TD="width: 10%, bgcolor: #ffffff"] 14
[/TD]
is called with the value of start as 0 it should return 7,
but if it is called with the value of start as 8 it should return 8.
PARTD
Use the above function of part C to write a selectionsort function to sort an array of integers in
ascending order (low to high).
 
PART F
Write a main function to test the above functions.
Declare an integer array named Arr with minimum size 50.
Read 10 integers into array Arr (call function readtarr)
Output the array before sorting( call function outputarr).
Sort the array using function selectionsort
Output the array after sorting( call function outputarr).
 
PART A
Write a function named outputarr that output the elements of an integer array.
PART B
Write a function named readarr that reads the elements of an integer array.
PART C
Write a function named
minPosition that takes an array of integers intList, and the
index of the first element in the array (start), and the size of the array. The function should return the Position (Location) of the
minimum value in the array (a number between start and size).
For example, if the following array intList :
44

[TD="width: 10%, bgcolor: #ffffff"] 9
[/TD]
[TD="width: 10%, bgcolor: #ffffff"] 7
[/TD]
[TD="width: 10%, bgcolor: #ffffff"] 14
[/TD]
[TD="width: 10%, bgcolor: #ffffff"] 17
[/TD]
[TD="width: 10%, bgcolor: #ffffff"] 12
[/TD]
[TD="width: 10%, bgcolor: #ffffff"] 15
[/TD]
[TD="width: 10%, bgcolor: #ffffff"] 3
[/TD]
[TD="width: 10%, bgcolor: #ffffff"] 6
[/TD]
[TD="width: 10%, bgcolor: #ffffff"] 14
[/TD]
is called with the value of start as 0 it should return 7,
but if it is called with the value of start as 8 it should return 8.
PARTD
Use the above function of part C to write a selectionsort function to sort an array of integers in
ascending order (low to high).
 
PART F
Write a main function to test the above functions.
Declare an integer array named Arr with minimum size 50.
Read 10 integers into array Arr (call function readtarr)
Output the array before sorting( call function outputarr).
Sort the array using function selectionsort
Output the array after sorting( call function outputarr).

==>
كود:
#include <iostream>
using namespace std;
void outputarr (int x[],int y)
{
     for(int i=0;i<y;i++)
         cout<<x[i]<<" ";
     cout<<endl;
}
void readarr (int x[],int y)
{
     for(int i=0;i<y;i++)
         cin>>x[i];
}
int minPosition (int intList[],int s,int y)
{
    int min=intList[s],pos=s;
    for (int i=s;i<y;i++)
    if (intList[i]<min){min=intList[i];pos=i;}
    return pos;
}
void selectionsort (int x[],int y)
{
     int temp;
     for (int i=0;i<y;i++)
     {
         temp=x[minPosition(x,i,y)];
         x[minPosition(x,i,y)]=x[i];
         x[i]=temp;
     }
}
int main()
{
    int Arr[20];
    cout<<"Enter 10 numbers :\n";
    readarr(Arr,10);
    cout<<"Your numbers :\n";
    outputarr(Arr,10);
    selectionsort(Arr,10);
    cout<<"Your numbers after sorting :\n";
    outputarr(Arr,10);
    system("pause");
    return 0;
}
 
write a program to read 10 names from file "names.dat" and print thier name length to file " namelength.dat".
In addition print the maximum and minimum length on screen.

كيف طريقة الحل ؟
 
سلام عليكم شعب .. ممكن مساعدتي في الحل .. فاهمتنه بس مو عارفه اكتب البرنامج

Usingthe “String Type” functions discussed in chapter 8 (find, substr, length, swap). Write a program that prompts the user to enter a word of an odd length. Your program should check that the entered word is of an odd length.The program shouldthen scramble the word by moving the middle character to the beginning of the word and output the new word.
 
write a program to read 10 names from file "names.dat" and print thier name length to file " namelength.dat".
In addition print the maximum and minimum length on screen.

كيف طريقة الحل ؟

==>

كود:
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int main()
{
    string str;
    int min=100,max=0;
    ifstream in;in.open("names.dat");
    ofstream out;out.open("namelength.dat");
    if (!in){cout<<"Erorr no file";return 1;}
    for(int i=0;i<10;i++)
    {
        in>>str;
        out<<str<<" "<<str.length()<<endl;
        if (str.length()<min)min=str.length();
        if (str.length()>max)max=str.length();
    }
    cout<<"Maximum name size : "<<max<<endl;
    cout<<"Maimum name size : "<<min<<endl;
    system("pause");
    return 0;
}
 
سلام عليكم شعب .. ممكن مساعدتي في الحل .. فاهمتنه بس مو عارفه اكتب البرنامج

Usingthe “String Type” functions discussed in chapter 8 (find, substr, length, swap). Write a program that prompts the user to enter a word of an odd length. Your program should check that the entered word is of an odd length.The program shouldthen scramble the word by moving the middle character to the beginning of the word and output the new word.

==>

كود:
#include <iostream>
#include <string>
using namespace std;
int main()
{
    string str;
    int mid;
    do
    {
        cout<<"Enter a word of an odd length :\n";
        cin>>str;
    }while (!(str.length()%2));
    mid=str.length()/2;
    str=str[mid]+str.substr(0,mid)+str.substr(mid+1);
    cout<<"\nNew word :\n"<<str<<endl;
    system("pause");
    return 0;
}
 
بلييز ساعدوني في حل هل المسألة جدي متوهقة فيها و مو عارفة احلها بأبسط طريقة ممكنة :nosweat:
:tears::tears:
Write function sequential search given in the class with a prgram to test it, then change the function to do the following:
1- return the maximum element of the array.​
2- return the maximum poisition of the maximum element.​
3- use the function to replace the maximum element of the array by -100.​
 
ITCS104

بلييز ساعدواني في حل هل المسألة مو عارفة احلها و متوهقة :tears:
بأبسط طريقة ممكنة رجاءا :nosweat:
Write function sequential search given in the class with a prgram to test it, then change the function to do the following: 1- return the maximum element of the array.
2- return the maximum poisition of the maximum element.
3- use the function to replace the maximum element of the array by -100.


​
 
سؤال ..
طالبين برنامج نكتب برنامج فيه فنكشن ترتب .. و فكنشن تقرأ و اليوزر الي يدخل الأرقام .. و الفنكشن الثالثه بتطبع

السايز من وين بناخذ قيمته ؟! يعني احنا نحدد على كيفنا ؟
 
عودة
أعلى أسفل