Home > Back-end >  C on string two-dimensional array assigned to a double array
C on string two-dimensional array assigned to a double array

Time:10-31

#include
#include
#include
using namespace std;
STD: : stringstream str2digit;
Class Staff
{
Private:
int i,j,k;
Double t;
Double sum [10], 'arry [10].
String name [10] [10].
Public:
The Staff ();
Void input ();
Void the output ();
Void computer ();
Void the put ();
};
Staff: : Staff ()
{
Cout<& lt;" Please enter the names of the ten employees: ";
for(i=0; i<=9; I++)
{cin> The name [I] [0]; }
}
Void Staff: : input ()
{
for(int i=0; i<=9; I++)
{
Cout<& lt;" Please input "& lt; for(int j=1; j<=4; J++)
{cin> The name [I] [j]; }
}
}

Void Staff: the output ()
{
for(int i=0; i<=9; I++)
{
Coutfor(int j=1; j<=4; J++)
{cout<& lt;" In the first "& lt; }
}

Void Staff: : computer ()
{
Double t=0.0;
for(int i=0; i<=9; I++)
{
for(int j=0; j<=4; J++)
{
Str2digit & lt; <(the name [I] [j]); Str2digit & gt;> t;
The sum + [I]=t;
}
Cout'arry [I]=sum [I]/4.0;
}
}

Void Staff: the put ()
{
For (k=0; K<=9; K++)
{
CoutCout}
}

Int main ()
{
The Staff s;
S.i nput ();
S.o utput ();
S.com puter ();
Supachai panitchpakdi ut ();
return 0;
}


Program is to write the names of the input ten employees and enter every four months 'salary
And output every four months salary and total wages and average wages

I used a string of two-dimensional array but I want to ask is in the computer inside the constructor of my idea is to put the string inside every four month respectively to double but checked a lot of data in the array finally as such is not the average wage and total wages

Want to ask you how the inside of the string value is converted to a double array references (novice don't spray may be a bit messy code)
  • Related