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

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

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

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

Write a function named removeExtraBlanks that takes two parameters: an array of characters (Sentence), and the number of characters in the array (Length), which is passed by reference. The function should remove all extra blanks in Sentence, i.e. for each two consecutive blanks, the function should remove the second blank character and decrement length accordingly. The function should also return the number of extra blanks removed from Sentence. Write a main program to test your function.

For example, If Length=10 and the content of Sentence before calling the function is:
[TABLE="align: left"]
[TR]
[TD][/TD]
[TD]1
[/TD]
[TD]2
[/TD]
[TD]3
[/TD]
[TD]4
[/TD]
[TD]5
[/TD]
[TD]6
[/TD]
[TD]7
[/TD]
[TD]8
[/TD]
[TD]9
[/TD]
[/TR]
[TR]
[TD]‘A’
[/TD]
[TD]‘ ‘
[/TD]
[TD]‘ ‘
[/TD]
[TD]‘ ‘
[/TD]
[TD]B
[/TD]
[TD]‘ ‘
[/TD]
[TD]‘ ‘
[/TD]
[TD]C
[/TD]
[TD]‘ ‘
[/TD]
[TD]D
[/TD]
[/TR]
[/TABLE]




Then, after calling the function: Length=7 and Sentence should be as follows:

[TABLE="align: left"]
[TR]
[TD][/TD]
[TD]1
[/TD]
[TD]2
[/TD]
[TD]3
[/TD]
[TD]4
[/TD]
[TD]5
[/TD]
[TD]6
[/TD]
[/TR]
[TR]
[TD]‘A’
[/TD]
[TD]‘ ‘
[/TD]
[TD]B
[/TD]
[TD]‘ ‘
[/TD]
[TD]C
[/TD]
[TD]‘ ‘
[/TD]
[TD]D
[/TD]
[/TR]
[/TABLE]


In addition, the function should return 3 (i.e. 3 blanks were removed)


محلول بالصفحات الي قبل
 
ممكن نشوف ابداعاتكم ...
انا حاولت احله بس ما بعرف اذا صح او لا؟؟
بس اخر بارت شيرت فيه وما اعرفت احله

PART(A)

  1. Write the definition of a structure type named nameType, which includesthe following components: firstName and lastName.
  2. Write the definition of a structure type named dateType, which include the following components: day, month, and year;
  3. Write the definition of a structure type named personalInfoType, which include the following components: ID of type long, name of type nameType, salary of type integer nd DateOfBirth of type dateType.
  4. Write a function named getData that take as parameter:
    1. Employees: an array of type personalInfoType.
    2. numEmployee: number of items in the Employees array.
The function should prompt the user to enter the ID, name, and DateofBirth of all Employees.

  1. Write a function named printData that take as parameter:
    1. Employees: an array of type personalInfoType.
    2. numEmployee: number of items in the Employees array.
The function should output the ID, name, and DateofBirth of all Employees.

  1. Write a function named bornSameYearMonth that take as parameter:
    1. Employees: an array of type personalInfoType.
    2. numEmployee:number of items in the Employees array.
    3. Emp1: of type personType.
The function should print the names (first name and last name)of all Employees born on the same month and year asEmp1.


  1. Write a function named IncreaseLowSalaries that takes array Employees of type personalInfoType and numEmployee of type int. Your function should print LastName of employees with salary below 200 and increment the salary by 50.
 
ممكن مساعدة :
a. Write the definition of a structure type named student that includes the following members: student ID, name, and an array of size five to represent students’ quiz grades.

b. Write a function named getData that takes a parameter X of type student. The function should read the data of X.


c. Write a function named printData that takes a parameter X of type student. The function should display the data of X.

d. Write a function named calculateAvg that takes a parameter X of type student. The function should calculate and return the average of X quiz grades.


e. Write a function named equal that takes two parameters X, and Y of type student. The function should return true if the Quiz array of X has the same content as the quiz grades of Y, otherwise the function should return false.

f. Write the definition of a structure type named section, which includes the following components: section number (secNo) of type int, number of students in the section (noStudents) of type int, room number (roomNo) of type string, and an array (studentsList) of type student of size 20.

g. Write a function named getData that takes as parameter: mySection of type section. The function should prompt the user to enter the data of mySection.

h. Write a function named printData that takes as parameter mySection of type section. The function should print the data of mySection.

i. Write a function named averageQuiz1 that takes as parameter mySection of type section. The function should return the average of first quiz for all students in the section

j. Write a function named topStudents that take as parameter: mySection of type section. The function should print the students’ names with quiz1 score greater than the average of quiz1 for all students. (Hint: use averageQuiz1 function to get the average of quiz1)
 
التعديل الأخير:
ممكن مساعدة :
a. Write the definition of a structure type named student that includes the following members: student ID, name, and an array of size five to represent students’ quiz grades.

b. Write a function named getData that takes a parameter X of type student. The function should read the data of X.


c. Write a function named printData that takes a parameter X of type student. The function should display the data of X.

d. Write a function named calculateAvg that takes a parameter X of type student. The function should calculate and return the average of X quiz grades.


e. Write a function named equal that takes two parameters X, and Y of type student. The function should return true if the Quiz array of X has the same content as the quiz grades of Y, otherwise the function should return false.

f. Write the definition of a structure type named section, which includes the following components: section number (secNo) of type int, number of students in the section (noStudents) of type int, room number (roomNo) of type string, and an array (studentsList) of type student of size 20.

g. Write a function named getData that takes as parameter: mySection of type section. The function should prompt the user to enter the data of mySection.

h. Write a function named printData that takes as parameter mySection of type section. The function should print the data of mySection.

i. Write a function named averageQuiz1 that takes as parameter mySection of type section. The function should return the average of first quiz for all students in the section

j. Write a function named topStudents that take as parameter: mySection of type section. The function should print the students’ names with quiz1 score greater than the average of quiz1 for all students. (Hint: use averageQuiz1 function to get the average of quiz1)

أعتقد يصير جذي .. رتبت كم حاجه :smile2:

كود:
#include<iostream>
#include<string>
using namespace std;
struct student{
	int id;
	string name;
	double grades[5];
};
struct section{
	int secNo,noStudents;
	string roomNo;
	student studentsList[20];
};
student x,y;
section mySection;
void getData(student& ){
	cout<<"Enter (ID + Name)"<<endl;
	cin>>x.id>>x.name;
	cout<<"Enter 5 quizzes grades "<<endl;
	for(int i=0;i<5;i++)
	cin>>x.grades[i];
}
void printData(student){
	cout<<"(ID + Name) :"<<endl;
	cout<<x.id<<" "<<x.name<<" "<<endl;
	cout<<"Quizzes grades :"<<endl;
	for(int i=0;i<5;i++)
		cout<<x.grades[i]<<" ";
	cout<<endl;
}
double calculateAvg(student){
	double sum=0.0, avr;
	for(int i=0;i<5;i++){
		sum+=x.grades[i];}
	avr=sum/5;
	return avr;
}
bool equal(student,student){
	for(int i=0;i<5;i++)
		if(x.grades[i]!=y.grades[i])
			return false;
	return true;
}
void getData(section&){
	cout<<"Enter the information saction: -Sec.NO,stu.NO,rom.NO-"<<endl;
	cin>>mySection.secNo>>mySection.noStudents>>mySection.roomNo;
	for(int i=0;i<mySection.noStudents;i++){
		cout<<"Enter student ID : "<<endl;
		cin>>mySection.studentsList[i].id;
		cout<<"Enter student name : "<<endl;
		cin>>mySection.studentsList[i].name;
		cout<<"Enter student 5 grades : "<<endl;
		for (int j=0;j<5;j++)
		cin>>mySection.studentsList[i].grades[j];}
} 
void printData(section){
	cout<<"Information saction: -Sec.NO,stu.NO,rom.NO-"<<endl;
	cout<<mySection.secNo<<" "<<mySection.noStudents<<" "<<mySection.roomNo<<endl;
	for(int i=0;i<mySection.noStudents;i++){
		cout<<"Student ID : "<<mySection.studentsList[i].id<<endl;
		cout<<"Student name : "<<mySection.studentsList[i].name<<endl;
		cout<<"Student grades : "<<endl;
		for (int j=0;j<5;j++)
			cout<<mySection.studentsList[i].grades[j]<<" ";}
	cout<<endl;
}
double averageQuiz1(section){
	double sum=0.0,avg;
	int count=0;
	for(int i=0;i<mySection.noStudents;i++)
		sum+=mySection.studentsList[i].grades[0];
	avg=sum/mySection.noStudents;
	return avg;
}
void topStudents(section){
	double avg;
	avg=averageQuiz1(mySection);
	for(int i=0;i<mySection.noStudents;i++){
		cout<<"Student name ... grade "<<endl;
		if(mySection.studentsList[i].grades[0]>avg)
			cout<<mySection.studentsList[i].name<<" "<<mySection.studentsList[i].grades[0];}
}
int main()
{
	
	cout<<"Enter the student 1 information:"<<endl;
	getData(y);
	cout<<"Enter the student 2 information:"<<endl;
	getData(x);
	cout<<"Avarage for sudent 1 : "<<calculateAvg(x)<<endl;
	if(equal(x,y))
		cout<<"Student 1&2 have same grades !!"<<endl;
	else
		cout<<"Student 1&2 have different grades !!"<<endl;
	cout<<endl;
	cout<<"student 1 info :"<<endl;
	printData(x);
	getData(mySection);
	printData(mySection);
	cout<<"Average for quizzes grade:"<<averageQuiz1(mySection)<<endl;
	cout<<"Student whoes over average:"<<endl;
	topStudents(mySection);
	system("pause");
	return 0;
}
 
  • Like
التفاعلات: ha
ممكن نشوف ابداعاتكم ...
انا حاولت احله بس ما بعرف اذا صح او لا؟؟
بس اخر بارت شيرت فيه وما اعرفت احله

PART(A)

  1. Write the definition of a structure type named nameType, which includesthe following components: firstName and lastName.
  2. Write the definition of a structure type named dateType, which include the following components: day, month, and year;
  3. Write the definition of a structure type named personalInfoType, which include the following components: ID of type long, name of type nameType, salary of type integer nd DateOfBirth of type dateType.
  4. Write a function named getData that take as parameter:
    1. Employees: an array of type personalInfoType.
    2. numEmployee: number of items in the Employees array.
The function should prompt the user to enter the ID, name, and DateofBirth of all Employees.

  1. Write a function named printData that take as parameter:
    1. Employees: an array of type personalInfoType.
    2. numEmployee: number of items in the Employees array.
The function should output the ID, name, and DateofBirth of all Employees.

  1. Write a function named bornSameYearMonth that take as parameter:
    1. Employees: an array of type personalInfoType.
    2. numEmployee:number of items in the Employees array.
    3. Emp1: of type personType.
The function should print the names (first name and last name)of all Employees born on the same month and year asEmp1.


  1. Write a function named IncreaseLowSalaries that takes array Employees of type personalInfoType and numEmployee of type int. Your function should print LastName of employees with salary below 200 and increment the salary by 50.

أعتقد يصير جذي .. :smile2:

كود:
//Noise-X
#include <iostream>
#include <string>
using namespace std;
struct nameType
	{
		string firstName,lastName;
	};
struct dateType
	{
		int day,month,year;
	};
struct personalInfoType
	{
		long ID;
		int salary;
		nameType name;
		dateType DateOfBirth;
	};
	personalInfoType Employees[5];
	personalInfoType Empl;
void getData (personalInfoType [],int numEmployee)
{
	for (int i=0;i<numEmployee;i++)
	{
		cout<<"Enter ID-salary-firstName-lastName-day-month-year :"<<endl;
		cin>>Employees[i].ID;
		cin>>Employees[i].salary;
		cin>>Employees[i].name.firstName;
		cin>>Employees[i].name.lastName;
		cin>>Employees[i].DateOfBirth.day;
		cin>>Employees[i].DateOfBirth.month;
		cin>>Employees[i].DateOfBirth.year;
		cout<<endl;
	}
}
void printData (personalInfoType [],int numEmployee)
{
	for (int i=0;i<numEmployee;i++)
	{
		cout<<"Employee "<<i+1<<" Info : "<<endl;
		cout<<Employees[i].ID<<endl;
		cout<<Employees[i].name.firstName<<endl;
		cout<<Employees[i].name.lastName<<endl;
		cout<<Employees[i].DateOfBirth.day<<endl;
		cout<<Employees[i].DateOfBirth.month<<endl;
		cout<<Employees[i].DateOfBirth.year<<endl;
		cout<<endl;
	}
}
void bornSameYearMonth (personalInfoType [],int numEmployee,personalInfoType)
{
	for (int i=0;i<numEmployee;i++)
		if (Employees[i].DateOfBirth.month==Empl.DateOfBirth.month){
			if (Employees[i].DateOfBirth.year==Empl.DateOfBirth.year){
				cout<<"bornSameYearMonth : "<<endl;
				cout<<"firstName "<<Employees[i].name.firstName<<endl;
				cout<<"lastName "<<Employees[i].name.lastName<<endl;}}
}
void IncreaseLowSalaries (personalInfoType [],int numEmployee)
{
	cout<<"Employees with salary below 200 :"<<endl;
	for (int i=0;i<numEmployee;i++)
		if (Employees[i].salary<200){
			cout<<Employees[i].name.lastName<<endl;
			Employees[i].salary+=50;}
}
int main()
{
	getData(Employees,5);
	Empl.DateOfBirth.day=24;
	Empl.DateOfBirth.month=9;
	Empl.DateOfBirth.year=1995;
	printData(Employees,5);
	bornSameYearMonth(Employees,5,Empl);
	IncreaseLowSalaries(Employees,5);
    return 0;
}
 
أعتقد يصير جذي .. رتبت كم حاجه :smile2:

كود:
#include<iostream>
#include<string>
using namespace std;
struct student{
    int id;
    string name;
    double grades[5];
};
struct section{
    int secNo,noStudents;
    string roomNo;
    student studentsList[20];
};
student x,y;
section mySection;
void getData(student& ){
    cout<<"Enter (ID + Name)"<<endl;
    cin>>x.id>>x.name;
    cout<<"Enter 5 quizzes grades "<<endl;
    for(int i=0;i<5;i++)
    cin>>x.grades[i];
}
void printData(student){
    cout<<"(ID + Name) :"<<endl;
    cout<<x.id<<" "<<x.name<<" "<<endl;
    cout<<"Quizzes grades :"<<endl;
    for(int i=0;i<5;i++)
        cout<<x.grades[i]<<" ";
    cout<<endl;
}
double calculateAvg(student){
    double sum=0.0, avr;
    for(int i=0;i<5;i++){
        sum+=x.grades[i];}
    avr=sum/5;
    return avr;
}
bool equal(student,student){
    for(int i=0;i<5;i++)
        if(x.grades[i]!=y.grades[i])
            return false;
    return true;
}
void getData(section&){
    cout<<"Enter the information saction: -Sec.NO,stu.NO,rom.NO-"<<endl;
    cin>>mySection.secNo>>mySection.noStudents>>mySection.roomNo;
    for(int i=0;i<mySection.noStudents;i++){
        cout<<"Enter student ID : "<<endl;
        cin>>mySection.studentsList[i].id;
        cout<<"Enter student name : "<<endl;
        cin>>mySection.studentsList[i].name;
        cout<<"Enter student 5 grades : "<<endl;
        for (int j=0;j<5;j++)
        cin>>mySection.studentsList[i].grades[j];}
} 
void printData(section){
    cout<<"Information saction: -Sec.NO,stu.NO,rom.NO-"<<endl;
    cout<<mySection.secNo<<" "<<mySection.noStudents<<" "<<mySection.roomNo<<endl;
    for(int i=0;i<mySection.noStudents;i++){
        cout<<"Student ID : "<<mySection.studentsList[i].id<<endl;
        cout<<"Student name : "<<mySection.studentsList[i].name<<endl;
        cout<<"Student grades : "<<endl;
        for (int j=0;j<5;j++)
            cout<<mySection.studentsList[i].grades[j]<<" ";}
    cout<<endl;
}
double averageQuiz1(section){
    double sum=0.0,avg;
    int count=0;
    for(int i=0;i<mySection.noStudents;i++)
        sum+=mySection.studentsList[i].grades[0];
    avg=sum/mySection.noStudents;
    return avg;
}
void topStudents(section){
    double avg;
    avg=averageQuiz1(mySection);
    for(int i=0;i<mySection.noStudents;i++){
        cout<<"Student name ... grade "<<endl;
        if(mySection.studentsList[i].grades[0]>avg)
            cout<<mySection.studentsList[i].name<<" "<<mySection.studentsList[i].grades[0];}
}
int main()
{
    
    cout<<"Enter the student 1 information:"<<endl;
    getData(y);
    cout<<"Enter the student 2 information:"<<endl;
    getData(x);
    cout<<"Avarage for sudent 1 : "<<calculateAvg(x)<<endl;
    if(equal(x,y))
        cout<<"Student 1&2 have same grades !!"<<endl;
    else
        cout<<"Student 1&2 have different grades !!"<<endl;
    cout<<endl;
    cout<<"student 1 info :"<<endl;
    printData(x);
    getData(mySection);
    printData(mySection);
    cout<<"Average for quizzes grade:"<<averageQuiz1(mySection)<<endl;
    cout<<"Student whoes over average:"<<endl;
    topStudents(mySection);
    system("pause");
    return 0;
}

جفت ردك عقب ماسويته
على العموم شكراً
:smile2:
 
السلام عليكم



عندي سؤال حليته بس يطلع لي 20 خطأ



هو محلول فوق وتقريبا نفس حلي بس لما احطه بالبرنامج ما يشتغل

هذآ السؤال
PART(A)

  1. Write the definition of a structure type named nameType, which includesthe following components: firstName and lastName.
  2. Write the definition of a structure type named dateType, which include the following components: day, month, and year;
  3. Write the definition of a structure type named personalInfoType, which include the following components: ID of type long, name of type nameType, salary of type integer nd DateOfBirth of type dateType.
  4. Write a function named getData that take as parameter:
    1. Employees: an array of type personalInfoType.
    2. numEmployee: number of items in the Employees array.
The function should prompt the user to enter the ID, name, and DateofBirth of all Employees.

  1. Write a function named printData that take as parameter:
    1. Employees: an array of type personalInfoType.
    2. numEmployee: number of items in the Employees array.
The function should output the ID, name, and DateofBirth of all Employees.

  1. Write a function named bornSameYearMonth that take as parameter:
    1. Employees: an array of type personalInfoType.
    2. numEmployee:number of items in the Employees array.
    3. Emp1: of type personType.
The function should print the names (first name and last name)of all Employees born on the same month and year asEmp1.


  1. Write a function named PrintLowSalaries that takes array Employees of type personalInfoType and numEmployee of type int. your function should print all IDs and LastName of employees with salary below 200 BD.


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

struct nameType 
{
    string firstName ; 
    string lastName ; 
};

struct dateType 
{ 
    int day , month , year ; 
};

struct personalInfoType
{ 
    long ID  ; 
    nameType name ; 
    int salary ; 
    dateType DateOfBirth ;
};


    personalInfoType Empl; 

void getData ( personalInfoType Employees[] , int numEmployee )
{ 
    for ( int i=0 ; i<numEmployee ; i++ ) 
    { 
        cin>>Employees[i].ID;
        cin>>Employees[i].salary;
        cin>>Employees[i].name.firstName;
        cin>>Employees[i].name.lastName ; 
        cin>>Employees[i].DateofBirth.day ;
        cin>>Employees[i].DateofBirth.month ;
        cin>>Employees[i].DateofBirth.year ;
        cout<<endl;

    }

}


void printData  ( personalInfoType Employees[] , int numEmployee )


{ 
    for ( int i=0 ; i<numEmployee ; i++ ) 
    { 
        cout<<"The Information of emploee "<<i+1<<" : "<<endl;
        cout<<Employees[i].ID<<endl ; 
        cout<<Employees[i].name.firstName<<" ";
        cout<<Employees[i].name.lastName <<endl;  
        cout<<Employees[i].DateofBirth.day<<"-";
        cout<<Employees[i].DateofBirth.month<<"-";
        cout<<Employees[i].DateofBirth.year <<endl ; 

    }

}

void bornSameYearMonth ( personalInfoType Employees[] , int numEmployee , personType Emp1 )
{

    for ( int i=0 ; i<numEmployee ; i++ ) 

    { 
        if( Employees[i].DateOfBirth.month == Emp1.DateOfBirth.month ) { if( Employees[i].DateOfBirth.year == Emp1.DateOfBirth.year )} 

        {

            cout<<Employees[i].name.firstName<<" "<<Employees[i].name.lastName<<endl;
        }
    }

}



void PrintLowSalaries ( personalInfoType Employees[] , int numEmployee )
{

    for ( int i=0 ; i<numEmployee ; i++ ) 

    { if( Employees[i].salary < 200) 

    { cout<<Employees[i].ID<<endl ; 
    cout<<Employees[i].name.lastName <<endl ; 
    }
    }
}



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

وبعد في بارت " f " من السؤال
شلون بسوي كول لهالنوع من الفنكشن




وبس :)
 
السلام عليكم



عندي سؤال حليته بس يطلع لي 20 خطأ



هو محلول فوق وتقريبا نفس حلي بس لما احطه بالبرنامج ما يشتغل

هذآ السؤال
PART(A)

  1. Write the definition of a structure type named nameType, which includesthe following components: firstName and lastName.
  2. Write the definition of a structure type named dateType, which include the following components: day, month, and year;
  3. Write the definition of a structure type named personalInfoType, which include the following components: ID of type long, name of type nameType, salary of type integer nd DateOfBirth of type dateType.
  4. Write a function named getData that take as parameter:
    1. Employees: an array of type personalInfoType.
    2. numEmployee: number of items in the Employees array.
The function should prompt the user to enter the ID, name, and DateofBirth of all Employees.

  1. Write a function named printData that take as parameter:
    1. Employees: an array of type personalInfoType.
    2. numEmployee: number of items in the Employees array.
The function should output the ID, name, and DateofBirth of all Employees.

  1. Write a function named bornSameYearMonth that take as parameter:
    1. Employees: an array of type personalInfoType.
    2. numEmployee:number of items in the Employees array.
    3. Emp1: of type personType.
The function should print the names (first name and last name)of all Employees born on the same month and year asEmp1.


  1. Write a function named PrintLowSalaries that takes array Employees of type personalInfoType and numEmployee of type int. your function should print all IDs and LastName of employees with salary below 200 BD.


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

struct nameType 
{
    string firstName ; 
    string lastName ; 
};

struct dateType 
{ 
    int day , month , year ; 
};

struct personalInfoType
{ 
    long ID  ; 
    nameType name ; 
    int salary ; 
    dateType DateOfBirth ;
};


    personalInfoType Empl; 

void getData ( personalInfoType Employees[] , int numEmployee )
{ 
    for ( int i=0 ; i<numEmployee ; i++ ) 
    { 
        cin>>Employees[i].ID;
        cin>>Employees[i].salary;
        cin>>Employees[i].name.firstName;
        cin>>Employees[i].name.lastName ; 
        cin>>Employees[i].DateofBirth.day ;
        cin>>Employees[i].DateofBirth.month ;
        cin>>Employees[i].DateofBirth.year ;
        cout<<endl;

    }

}


void printData  ( personalInfoType Employees[] , int numEmployee )


{ 
    for ( int i=0 ; i<numEmployee ; i++ ) 
    { 
        cout<<"The Information of emploee "<<i+1<<" : "<<endl;
        cout<<Employees[i].ID<<endl ; 
        cout<<Employees[i].name.firstName<<" ";
        cout<<Employees[i].name.lastName <<endl;  
        cout<<Employees[i].DateofBirth.day<<"-";
        cout<<Employees[i].DateofBirth.month<<"-";
        cout<<Employees[i].DateofBirth.year <<endl ; 

    }

}

void bornSameYearMonth ( personalInfoType Employees[] , int numEmployee , personType Emp1 )
{

    for ( int i=0 ; i<numEmployee ; i++ ) 

    { 
        if( Employees[i].DateOfBirth.month == Emp1.DateOfBirth.month ) { if( Employees[i].DateOfBirth.year == Emp1.DateOfBirth.year )} 

        {

            cout<<Employees[i].name.firstName<<" "<<Employees[i].name.lastName<<endl;
        }
    }

}



void PrintLowSalaries ( personalInfoType Employees[] , int numEmployee )
{

    for ( int i=0 ; i<numEmployee ; i++ ) 

    { if( Employees[i].salary < 200) 

    { cout<<Employees[i].ID<<endl ; 
    cout<<Employees[i].name.lastName <<endl ; 
    }
    }
}



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

وبعد في بارت " f " من السؤال
شلون بسوي كول لهالنوع من الفنكشن




وبس :)

الأخطاء .. :nosweat:
- "
DateOfBirth " مخلينها " DateofBirth "
- "
personalInfoType " مخلينها " personType "
- "
Emp1 " مخلينها " Empl "

هذا كول الفنكشن .. :smile2:
كود:
bornSameYearMonth(Employees,5,Emp1)
الرقم 5 يتغير حسب الحجم اللي مخلينه للـ " Employees ".
 
أعتقد يصير جذي .. :smile2:

كود:
//Noise-X
#include <iostream>
#include <string>
using namespace std;
struct nameType
    {
        string firstName,lastName;
    };
struct dateType
    {
        int day,month,year;
    };
struct personalInfoType
    {
        long ID;
        int salary;
        nameType name;
        dateType DateOfBirth;
    };
    personalInfoType Employees[5];
    personalInfoType Empl;
void getData (personalInfoType [],int numEmployee)
{
    for (int i=0;i<numEmployee;i++)
    {
        cout<<"Enter ID-salary-firstName-lastName-day-month-year :"<<endl;
        cin>>Employees[i].ID;
        cin>>Employees[i].salary;
        cin>>Employees[i].name.firstName;
        cin>>Employees[i].name.lastName;
        cin>>Employees[i].DateOfBirth.day;
        cin>>Employees[i].DateOfBirth.month;
        cin>>Employees[i].DateOfBirth.year;
        cout<<endl;
    }
}
void printData (personalInfoType [],int numEmployee)
{
    for (int i=0;i<numEmployee;i++)
    {
        cout<<"Employee "<<i+1<<" Info : "<<endl;
        cout<<Employees[i].ID<<endl;
        cout<<Employees[i].name.firstName<<endl;
        cout<<Employees[i].name.lastName<<endl;
        cout<<Employees[i].DateOfBirth.day<<endl;
        cout<<Employees[i].DateOfBirth.month<<endl;
        cout<<Employees[i].DateOfBirth.year<<endl;
        cout<<endl;
    }
}
void bornSameYearMonth (personalInfoType [],int numEmployee,personalInfoType)
{
    for (int i=0;i<numEmployee;i++)
        if (Employees[i].DateOfBirth.month==Empl.DateOfBirth.month){
            if (Employees[i].DateOfBirth.year==Empl.DateOfBirth.year){
                cout<<"bornSameYearMonth : "<<endl;
                cout<<"firstName "<<Employees[i].name.firstName<<endl;
                cout<<"lastName "<<Employees[i].name.lastName<<endl;}}
}
void IncreaseLowSalaries (personalInfoType [],int numEmployee)
{
    cout<<"Employees with salary below 200 :"<<endl;
    for (int i=0;i<numEmployee;i++)
        if (Employees[i].salary<200){
            cout<<Employees[i].name.lastName<<endl;
            Employees[i].salary+=50;}
}
int main()
{
    getData(Employees,5);
    Empl.DateOfBirth.day=24;
    Empl.DateOfBirth.month=9;
    Empl.DateOfBirth.year=1995;
    printData(Employees,5);
    bornSameYearMonth(Employees,5,Empl);
    IncreaseLowSalaries(Employees,5);
    return 0;
}

شكرا كتير خيو ... اشتغل البرنامج
 
-


السلام عليكم ورحمة الله وبركاته



هلون صح الفنكشن حق هالسؤالين

Problem 1: Write a function named searchForLastOccurence that takes as parameters an array of integers, an integer key value, and the array size. The function should search for the last occurrence of the key value in the array and return its position in the array, OR return -1 if the value is not found in the array. The function prototype is:
int searchForLastOccurence(int arr[], int key, int size);


HTML:
int searchForLastOccurence ( int arr[] , int key , int size )
{ 
 for ( int i=size-1 ;i<0;i--)
if( arr[i]== key ) return i ;
 return -1 ;
}

Problem 2: Write a function named displayAllOccurences that takes as parameters an array of integers, an integer key value, and the array size. The function should search for all occurrences of the key value in the array and display their position in the array, if the value is not found in the array, the function should display a message saying that the value is not found in the array. The function prototype is:
void displayAllOccurences(int arr[], int key, int size);




HTML:
void displayAllOccurences(int arr[], int key, int size )
{ 
 for ( int i=0 ;i<size ;i++)
{   if( arr[i]== key ) cout<<"found at "<<i;}


 cout<<" The value is not found in the array ";

}


وهذآ السؤال فهمته بس مو عارفه كيف اترجمه لفنكشن

Problem 3: Write a function named insertNewElement that takes four parameters: an array of integers (List), an integer (newItem), the number of elements in the array (Length), and the maximum size of the array (Max_Size). Assume that the elements in the array are sorted in ascending order. The function should add newItem in a way that the element in the array will remain sorted. Note that the Length of the array should not exceed Max_Size, i.e. if List is full, then the insertion is not performed and an appropriate message is displayed. The prototype of the function is:
void insertNewElement (int List[], int newItem, int & Length, const int Max_Size);
 
-


السلام عليكم ورحمة الله وبركاته



هلون صح الفنكشن حق هالسؤالين

Problem 1: Write a function named searchForLastOccurence that takes as parameters an array of integers, an integer key value, and the array size. The function should search for the last occurrence of the key value in the array and return its position in the array, OR return -1 if the value is not found in the array. The function prototype is:
int searchForLastOccurence(int arr[], int key, int size);


HTML:
int searchForLastOccurence ( int arr[] , int key , int size )
{ 
 for ( int i=size-1 ;i<0;i--)
if( arr[i]== key ) return i ;
 return -1 ;
}

Problem 2: Write a function named displayAllOccurences that takes as parameters an array of integers, an integer key value, and the array size. The function should search for all occurrences of the key value in the array and display their position in the array, if the value is not found in the array, the function should display a message saying that the value is not found in the array. The function prototype is:
void displayAllOccurences(int arr[], int key, int size);




HTML:
void displayAllOccurences(int arr[], int key, int size )
{ 
 for ( int i=0 ;i<size ;i++)
{   if( arr[i]== key ) cout<<"found at "<<i;}


 cout<<" The value is not found in the array ";

}


وهذآ السؤال فهمته بس مو عارفه كيف اترجمه لفنكشن

Problem 3: Write a function named insertNewElement that takes four parameters: an array of integers (List), an integer (newItem), the number of elements in the array (Length), and the maximum size of the array (Max_Size). Assume that the elements in the array are sorted in ascending order. The function should add newItem in a way that the element in the array will remain sorted. Note that the Length of the array should not exceed Max_Size, i.e. if List is full, then the insertion is not performed and an appropriate message is displayed. The prototype of the function is:
void insertNewElement (int List[], int newItem, int & Length, const int Max_Size);

هذي الفنكشنات .. << جمع فنكشن :RpS_lol:

كود:
int searchForLastOccurence ( int arr[] , int key , int size )
{ 
    int c=-1;
    for ( int i=size-1 ;i<0;i--)
    if( arr[i]== key ) c=i;
    return c ;
}

كود:
void displayAllOccurences(int arr[], int key, int size )
{ 
    int c=0;
    for ( int i=0 ;i<size ;i++)
        if( arr[i]== key ){cout<<"found at "<<i;c=1;}
    if(c==0)
    cout<<" The value is not found in the array ";
}

كود:
void insertNewElement (int List[], int newItem, int & Length, const int Max_Size)
{
    if (Length<Max_Size)
    {
        for (int i=0;i<Length;i++)
            if (newItem<List[i])
            {
                for (int j=Length;j>=i;j--)
                    List[j+1]=List[j];
                List[i]=newItem;
                Length++;
                break;
            }
    }
    else cout<<"It is max size !!"<<endl;
}
 
هذي الفنكشنات .. << جمع فنكشن :RpS_lol:

كود:
int searchForLastOccurence ( int arr[] , int key , int size )
{ 
    int c=-1;
    for ( int i=size-1 ;i<0;i--)
    if( arr[i]== key ) c=i;
    return c ;
}

كود:
void displayAllOccurences(int arr[], int key, int size )
{ 
    int c=0;
    for ( int i=0 ;i<size ;i++)
        if( arr[i]== key ){cout<<"found at "<<i;c=1;}
    if(c==0)
    cout<<" The value is not found in the array ";
}

كود:
void insertNewElement (int List[], int newItem, int & Length, const int Max_Size)
{
    if (Length<Max_Size)
    {
        for (int i=0;i<Length;i++)
            if (newItem<List[i])
            {
                for (int j=Length;j>=i;j--)
                    List[j+1]=List[j];
                List[i]=newItem;
                Length++;
                break;
            }
    }
    else cout<<"It is max size !!"<<endl;
}


شكرا ع الفنكشنات

:)
 
3ndi s1al, fee el bb website y6l4ley a5r s2al chthy

Write a function named PrintLowSalaries that takes array Employees of type personalInfoType and numEmployee of type int. your function should print all IDs and LastName of employees with salary below 200 BD

lakn achoof nas katbeen esu2al chthy

Write a function named IncreaseLowSalaries that takes array Employees of type personalInfoType and numEmployee of type int. Your function should print LastName of employees with salary below 200 and increment the salary by 50

el mushkela ena el website maga3d ytft7 fa moogadra at2kad mmkn a7d egooly ay wa7d el ma6loob
 
3ndi s1al, fee el bb website y6l4ley a5r s2al chthy

lakn achoof nas katbeen esu2al chthy


​
el mushkela ena el website maga3d ytft7 fa moogadra at2kad mmkn a7d egooly ay wa7d el ma6loob

ترجمة .. لاهنتم :RpS_tongue:

طاحت الربية ..
:RpS_lol:
في ناس سؤالهم الأول وناس سؤالهم الثاني .. فلازم تتأكدون من الموقع أي سؤال عندكم أفضل :smile2:
 
سلام
لو سمحتون ممكن أذا في احد عند دكتورة نهلة سكشن 07 يحط سؤال الهوم اسايمنت
البلاك بورد ما يفتح عندنا ومتورطين حدنا
 
سلام عليكم ..

في احد عنده شرح لدرس الستراكجر .. ستراكجر بدون الاري
لأن مع الاري عندي اني .. بكره عندي كويز فيه وماعندي النوت ليه !

احد يقدر يساعدني ..
 
اذا للدكتورة ميادة بعد يكوون افضل :tongue343:
 
سلام عليكم ..

في احد عنده شرح لدرس الستراكجر .. ستراكجر بدون الاري
لأن مع الاري عندي اني .. بكره عندي كويز فيه وماعندي النوت ليه !

احد يقدر يساعدني ..

اذا للدكتورة ميادة بعد يكوون افضل

إذا تبون شرح للدكتور " أنا " << :bleh:

هذا شرح جبتر 11 د.يوسف الحراث
https://www.uob-bh.com/forum/downloads.php?do=file&id=1652
 
سلام
ممكن تشوفون ليي الغلط في هالبرنامج
يطلع ليي 29 ايرور
HTML:
#include<iostream>#include <string>using namespace std;struct nameType{string firstName;string lastName;};struct dateType{int day;int month;int year;};struct personalInfoType {long ID;nameType name;int salary;dateType  DateOfBirth;};personalInfoType Emp1 ;void getData(personalInfoType Employees[], int numEmployee){cout<<"enter your name,id and DateofBirth";for(int i=0;i<numEmployee;i++)cin>>Employees[i].ID>>Employees[i].name.firstName>>Employees[i].name.lastName>>Employees[i].DateofBirth.day>>Employees[i].DateofBirth.month>>Employees[i].DateOfBirth.day;}void printData(	personalInfoType Employees[],int numEmployee){for(int i=0;i<numEmployee;i++)cout<<Employees[i].ID<<endl;cout<<Employees[i].name.firstName<<endl;cout<<Employees[i].name.lastName<<endl;cout<<Employees[i].DateofBirth.year<<endl,cout<<Employees[i].DateOfBirth.month<<endl;cout<<Employees[i].DateOfBirth.day<<endl;}void bornSameYearMonth(personalInfoType Employees[], int numEmployee,personalInfoType  Emp1){for (int i=0,i<numEmployee;i++){if (Emp1.DateofBirth.year==Employees[i].DateofBirth.year&&Emp1.DateOfBirth.day==Employees[i].DateOfBirth.day)cout<<Employees[i].name.firstName<<endl;cout<<Employees[i].name.lastName<<endl;	}}	void PrintLowSalaries(personalInfoType Employees[],int numEmployee){cout<<"theemployees with salary less than 200 are";for (int i=0; i<numEmployee; i++){if (Employees[i].salary<200)cout<<Employees[i].ID<<endl;cout<<Employees[i].name.lastName<<endl;}
 
عودة
أعلى أسفل