Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- int main()
- {
- int n,min[3],max[3];
- int sum[] = {0,0,0};
- cout<<"How many students? ";
- cin>>n;
- float score[3][n];
- for( int i = 0 ; i < 3 ; i++ )
- {
- cout<<"Enter scores of subject no."<<i+1<<endl;
- for( int j = 0 ; j < n ; j++ )
- {
- cin>>score[i][j];
- sum[i] += score[i][j];
- }
- }
- float avg[3],sigma[3];
- for(int k = 0 ; k < 3 ; k++)
- {
- avg[k] = sum[k]/n;
- min[k] = max[k] = score[k][0];
- for(int l = 0 ; l < n ; l++)
- {
- sigma[k] += pow(score[k][l] - avg[k] , 2);
- if(score[k][l] > max[k])
- {
- max[k] = score[k][l];
- }
- if(score[k][l] < min[k])
- {
- min[k] = score[k][l];
- }
- }
- }
- for(int m = 0 ; m < 3 ; m++)
- {
- cout<<"Max"<<m+1<<" = "<<max[m]<<"\t";
- cout<<"Min"<<m+1<<" = "<<min[m]<<"\t";
- cout<<"Avg"<<m+1<<" = "<<avg[m]<<"\t";
- cout<<"SD"<<m+1<<" = "<<sqrt(sigma[m]/n)<<endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement