SHARE
TWEET

qwejkdkw

a guest Feb 20th, 2020 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <fstream>
  2. struct _uniforma
  3. {
  4.     int marime, numarCopii;
  5. };
  6. int main()
  7. {
  8.     std::ifstream fin("serbare.in");
  9.     std::ofstream fout("serbare.out");
  10.     _uniforma uniforma[15], aux;
  11.     int copii, uniforme, marimi[15] = {0};
  12.     fin >> copii >> uniforme;
  13.     for(int i = 1; i <= copii; i++)
  14.     {
  15.         int marime, nrCopii;
  16.         fin >> nrCopii >> marime;
  17.         marimi[marime] += nrCopii;
  18.     }
  19.     for(int i = 1; i <= uniforme; i++)
  20.     {
  21.         uniforma[i].marime = i;
  22.         uniforma[i].numarCopii = marimi[i];
  23.     }
  24.     for(int i = 1; i < uniforme; i++) for(int j = i + 1; j <= uniforme; j++) if(uniforma[i].numarCopii < uniforma[j].numarCopii)
  25.             {
  26.                 aux = uniforma[i];
  27.                 uniforma[i] = uniforma[j];
  28.                 uniforma[j] = aux;
  29.             }
  30.     for(int i = 1; i <= uniforme; i++) fout << uniforma[i].marime << ' ';
  31.     return 0;
  32. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top