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


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

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

حل سؤال الموظفين والرواتب

4 مشترك

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

حل سؤال الموظفين والرواتب  Empty حل سؤال الموظفين والرواتب

مُساهمة من طرف anas mohtaseb 28/3/2011, 12:50 pm

الكود:
#include <iostream>
#include <string>


using namespace std;

int main(){
  int emp[5][3],i,j,sum=0,max,index;
  float avg;
    string s[5];
   cout<<"enter names\n";
   for (i = 0; i < 5; i++)
      getline(cin,s[i]);

for(i=0;i<5;i++)
{cout<<"enter the sal and month for emp # "<<i+1<<endl;
for(j=0;j<2;j++)
{
cin>>emp[i][j];
}
}
for(i=0;i<5;i++)
{
emp[i][2]=emp[i][0]*emp[i][1];
}
max=emp[0][0];
for(i=0;i<5;i++)
{    if (emp[i][0]>max)
    {
   max=emp[i][0];
  index=i;
    }
sum=sum+emp[i][0];
}
avg=sum/5.0;
cout<<"\n the avg = "<<avg<<endl;
cout<<"max sal ="<<max<<endl;
cout<<"name of max sal "<<s[index];

for(i=0;i<5;i++)
{
for(j=0;j<3;j++)
{
   cout<<emp[i][j]<<"\t";
}
cout<<endl;
}
   system("pause");
   return 0;
}
anas mohtaseb
anas mohtaseb

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

https://www.facebook.com/anasmohtaseb

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

حل سؤال الموظفين والرواتب  Empty رد: حل سؤال الموظفين والرواتب

مُساهمة من طرف hana 28/3/2011, 1:41 pm

شكرا الك اخ انس

hana

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

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

حل سؤال الموظفين والرواتب  Empty رد: حل سؤال الموظفين والرواتب

مُساهمة من طرف anas mohtaseb 28/3/2011, 2:00 pm

شكرا الك اخ انس

حياكم الله
anas mohtaseb
anas mohtaseb

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

https://www.facebook.com/anasmohtaseb

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

حل سؤال الموظفين والرواتب  Empty رد: حل سؤال الموظفين والرواتب

مُساهمة من طرف anas mohtaseb 2/4/2011, 6:16 pm

او الحل على طريقتي Smile


الكود:
    #include <iostream>
    #include <string>


    using namespace std;

    int main(){
      int emp[4][3],i,j,sum=0,max,index,x,w;
      float avg;
      string name[4];
      cout<<"enter names\n";
 
    
 //input name:-
   for (i=0;i<3;i++)
        cin>>name[i];

 //input salary and count of month:-
   for (i=0;i<3;i++)
        {cout<<"\nenter salary and count month to \t"<<name[i]<<"\n";

        cout<<"sulsry =\t";
           cin>>emp[i][0];

        cout<<"count month =\t";
           cin>>emp[i][1];       
        }


for(i=0;i<3;i++)
emp[i][2]=(emp[i][0]*emp[i][1]);

cout<<"\n\n\n***************************************\n";
cout<<"\t^_^name\tsalary\tmonth\ttotal ^_^\n";
cout<<"***************************************\n";

     for (i=0;i<3;i++){
        cout<<"\t"<<name[i]<<"\t";
     for(j=0;j<3;j++)
        cout<<emp[i][j]<<"\t";
cout<<endl;
     }
cout<<"***************************************\n";


//avareg salarys
     for (i=0;i<3;i++)
      sum=sum+emp[i][0];
     avg=sum/3;
     cout<<"\n\navareg salary = "<<avg;


// maximam sulary
     max=emp[0][0];

 for (i=0;i<3;i++)
    if (emp[i][0]>max){
    max=emp[i][0];
    index=i;
    }

   
        cout<<"\n\nmaximam salary \t"<<name[index]<<"\t";

        cout<<emp[index][0]<<"\t\n\n";




        cout<<"swap\nenter swap betwen\t note: *enter index*\n";
           cin>>x;
        cout<<"and\n";
           cin>>w;

name[3]=name[x];
name[x]=name[w];
name[w]=name[3];

 for (i=0;i<3;i++)
       emp[3][i]=emp[x][i];

 for (i=0;i<3;i++)
       emp[x][i]=emp[w][i];
for (i=0;i<3;i++)
       emp[w][i]=emp[3][i];




cout<<"\n\n\n***************************************\n";
cout<<"\t^_^name\tsalary\tmonth\ttotal ^_^\n";
cout<<"***************************************\n";

     for (i=0;i<3;i++){
        cout<<"\t"<<name[i]<<"\t";
     for(j=0;j<3;j++)
        cout<<emp[i][j]<<"\t";
cout<<endl;
     }
cout<<"***************************************\n";



      system("pause");
      return 0;
    }

ملاحظة :- فقط ل 3 موظفين ليس 5
anas mohtaseb
anas mohtaseb

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

https://www.facebook.com/anasmohtaseb

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

حل سؤال الموظفين والرواتب  Empty رد: حل سؤال الموظفين والرواتب

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

او الحل على طريقتي ^__^




الكود:
#include <iostream>
#include <string>

#define w 50
#define row 5
#define column 3
using namespace std;
int main(){
   int i,j,info[row][column],maxsalary,s=0,tempsalary,tempmonth,temptotalsalary,x,y;
   char name[row][w],tempname[1][w];
   float avgsalary=0,avgmonths=0;
   cout<<"enter 5 names of emploees: ";
for(i=0;i<row;i++)
{
cin>>name[i];
}
cout<<"enter the salary and num of worked month\n";
cout<<"name  "<<"salary "<<"months"<<endl;
cout<<"----  "<<"------ "<<"------"<<endl;

for (i=0;i<row;i++){
   cout<<name[i]<<"\t";
   for(j=0;j<column-1;j++){
      cin>> info[i][j];}
info[i][column-1]=info[i][0]*info[i][1];
   }
cout<<endl;
cout<<"All information you enter as the following:\n"
   <<"*******************************************\n";
cout<<"name  "<<"salary "<<"months "<<"total salary"<<endl;
cout<<"----  "<<"------ "<<"------ "<<"------------"<<endl;
for(i=0;i<row;i++){
   cout<<name[i]<<"    ";
for(j=0;j<column;j++){
   cout<<info[i][j]<<"    ";}
cout<<endl;}


for(i=0;i<row;i++){
avgsalary=avgsalary+info[i][0];
avgmonths=avgmonths+info[i][1];}
cout<<endl;
cout<<"other details:\n"
   <<"-------------\n"
   <<"the avrrage salary of all emploees= "<<float(avgsalary/row)<<endl
   <<"the avrrage number of months worked by emploees= "<<float(avgmonths/row)<<endl;
maxsalary=info[0][0];
for(i=1;i<row;i++){
   if(maxsalary<info[i][0]){
maxsalary=info[i][0];
s=i;}
   }
   cout<<"the name of the employee who has the maximum salary is; "<<name[s]<<endl;

cout<<endl<<endl;
cout<<"choose two emploees index to swap them: ";
cin>>x>>y;
strcpy(tempname[x],name[x]);
strcpy(name[x],name[y]);
strcpy(name[y],tempname[x]);
tempsalary=info[x][0];
info[x][0]=info[y][0];
info[y][0]=tempsalary;
tempmonth=info[x][1];
info[x][1]=info[y][1];
info[y][1]=tempmonth;
temptotalsalary=info[x][2];
info[x][2]=info[y][2];
info[y][2]=temptotalsalary;

cout<<"the informations after swaping are:\n"
   <<"-----------------------------------\n";
cout<<"name  "<<"salary "<<"months "<<"total salary"<<endl;
cout<<"----  "<<"------ "<<"------ "<<"------------"<<endl;
for(i=0;i<row;i++){
   cout<<name[i]<<"    ";
for(j=0;j<column;j++){
   cout<<info[i][j]<<"    ";}
cout<<endl;}


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

الحل لخمسة موظفين
بالتوفيق
Basel Tamimi
Basel Tamimi

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

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

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

حل سؤال الموظفين والرواتب  Empty رد: حل سؤال الموظفين والرواتب

مُساهمة من طرف باعامر 21/5/2011, 3:24 pm

شكرا لكم لهذه الموضوع Smile

باعامر

عدد المساهمات : 1
تاريخ التسجيل : 21/05/2011

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

حل سؤال الموظفين والرواتب  Empty رد: حل سؤال الموظفين والرواتب

مُساهمة من طرف anas mohtaseb 21/5/2011, 3:49 pm

باعامر كتب:شكرا لكم لهذه الموضوع Smile
العفو اخي الكريم
وكل التحية لاهل اليمن وطلاب الحديدة cheers
بس شو بالنسبة لعلي مطول عندكم ولا لا
anas mohtaseb
anas mohtaseb

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

https://www.facebook.com/anasmohtaseb

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

حل سؤال الموظفين والرواتب  Empty رد: حل سؤال الموظفين والرواتب

مُساهمة من طرف Basel Tamimi 22/5/2011, 3:17 pm

باعامر كتب:شكرا لكم لهذه الموضوع Smile

Welcome ^__^
Basel Tamimi
Basel Tamimi

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

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

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

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

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

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