মঙ্গলবার, ১৫ মার্চ, ২০১৬

lightOj 1249 - Chocolate Thief solve by c++

#include<iostream>
#include<string.h>
using namespace std;

int main()
{
  int a, b, c, test, k, n,l, v, max, min, i;
   char str[21], s1[21],s2[21];
   cin >> test;
   for(i = 1; i <= test; i++)
   {   cin >> n;
       cin >> str >> a >> b >> c;
       max = min = a * b * c;
       for(k = 1; k < n; k++)
       {
           cin >> str >> a >> b >> c;
           v = a * b * c;
          if (v > max) {
            strcpy (s1 , str);
            max = v;
         }
         else if (v < min) {
            strcpy (s2 , str);
            min = v;
         }
       }
       if(max == min) cout << "Case " << ": " << i << "no thief" << endl;
       else cout << "Case " << ": " << i << s1 << " took chocolate from " << s2 << endl;
   }
    return 0;
}



ahmed shuvo969
আহমেদ শুভ৯৬৯

1 টি মন্তব্য:

  1. #include
    using namespace std;

    int main(){

    int t,a=1;
    cin >> t;
    while(t--){

    int n,k=0,found=0;
    cin >> n;

    string s[n],thief,victim;

    int l[n],w[n],h[n],vol[n],consv;

    for(int i = 0 ; i < n ; i++){
    cin >> s[i] >> l[i] >> w[i] >> h[i];
    vol[i]=l[i]*w[i]*h[i];
    }

    for(int i = 1 ; i < n ; i++){
    if(vol[i] == vol[i-1]){
    consv=vol[i];
    break;
    }
    }

    for(int j = 0 ; j < n ; j++){
    if(vol[j] > consv){
    thief=s[j];
    found++;
    }
    if(vol[j] < consv){
    victim=s[j];
    }
    }

    if(found==0) printf("Case %d: no thief\n",a);
    else cout << "Case " << a << ": " << thief << " took chocolate from " << victim << endl;

    //else printf("%s took chocolate from %s\n",thief,victim);
    a++;
    }

    return 0;
    }

    ei code dile wrong answer hoche...please help

    উত্তরমুছুন