URI problem solved 16028317 1182 Column in Array : in C++



/*** Solve :: Try yourself first  ***/
uri-1182-solution || URI-online-judge
URI-1182-solve


Problem Details: Click to see full problem...

Solution in C++:

#include <iostream>
#include<iomanip>

using namespace std;

int main()
{
    int C,x,y;char T[2];double aa=0.0, M[12][12];
    cin>>C;
    cin>>T;
    for(int x=0;x<12;x++){
        for(int y=0;y<12;y++){
           // double num;
            scanf("%lf",&M[x][y]);
            if(y==C){
                aa = aa+ M[x][y];
            }
        }
    }

    if(T[0] == 'S') cout<<fixed<<setprecision(1)<<aa<<endl;
    else if(T[0] == 'M'){ cout<<fixed<<setprecision(1)<<aa/12.0<<endl;}
    return 0;
}



Comments

Post a Comment

Thanks for your message