Advertisement
informaticage

Template soluzione OIS Plugs

Jan 28th, 2020
288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.47 KB | None | 0 0
  1. #include<iostream>
  2. #include<vector>
  3. #include<algorithm>
  4.  
  5. using namespace std;
  6.  
  7. struct Computer {
  8.     string presa;
  9.     int potenza;
  10. };
  11.  
  12. int main ( void ) {
  13.     int numeroComputer, numeroPrese;
  14.  
  15.     vector <int> potenzeL10;
  16.     vector <int> potenzeL16;
  17.  
  18.     cin >> numeroComputer >> numeroPrese;
  19.  
  20.     vector<Computer> computers ( numeroComputer );
  21.  
  22.     for ( int i = 0; i < numeroComputer; i++ )
  23.         cin >> computers[i].potenza;
  24.  
  25.     for ( int i = 0; i < numeroComputer; i++ )
  26.         cin >> computers[i].presa;
  27.  
  28.     for ( int i = 0; i < numeroComputer; i++ ) {
  29.         if ( computers[i].presa == "L10" )
  30.             potenzeL10.push_back ( computers[ i ].potenza );
  31.  
  32.         if ( computers[i].presa == "L16" )
  33.             potenzeL16.push_back ( computers[ i ].potenza );
  34.     }
  35.  
  36.     sort ( potenzeL10.begin(), potenzeL10.end() );
  37.     sort ( potenzeL16.begin(), potenzeL16.end() );
  38.  
  39.     int numeroPreseL10 = 0;
  40.     int numeroPreseL16 = 0;
  41.     int numeroPreseBipasso = 0;
  42.  
  43.     for ( int i = 0; i < numeroPrese; i++ ) {
  44.         string presa;
  45.         cin >> presa;
  46.  
  47.         if ( presa == "L10" )
  48.             numeroPreseL10++;
  49.  
  50.         if ( presa == "L16" )
  51.             numeroPreseL16++;
  52.  
  53.         if ( presa == "bipasso" )
  54.             numeroPreseBipasso++;
  55.     }
  56.  
  57.     cout << "Prese L10: " << numeroPreseL10 << endl;
  58.     cout << "Prese L16: " << numeroPreseL16 << endl;
  59.     cout << "Prese bipasso: " << numeroPreseBipasso << endl;
  60.  
  61.     return 0;
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement