vitormartinotti

Aula 1 STL PM/PJ

Sep 2nd, 2026
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.81 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     //VECTOR
  8.     vector<int> tosta;
  9.    
  10.     for(int i = 1; i <= 5; i++){
  11.         int n;
  12.         scanf("%d", &n);
  13.         tosta.push_back(n);
  14.     }
  15.    
  16.     sort(tosta.begin(),tosta.end());
  17.    
  18.     //Seja tosta = {30,42,50,70,80}
  19.     int resp1 = *upper_bound(tosta.begin(),tosta.end(),42) //resp1 = 50
  20.     int resp2 = *lower_bound(tosta.begin(),tosta.end(),42) //resp2 = 42
  21.    
  22.     for(int i = 0; i < 5; i++){
  23.         printf("%d ", tosta[i]);
  24.     }
  25.    
  26.     //PAIR
  27.    
  28.     vector<pair<int,int>> lista;
  29.    
  30.     pair<int,int> teo;
  31.     teo.first = 6;
  32.     teo.second = 7;
  33.    
  34.     tosta.push_back(teo)
  35.    
  36.     printf("%d %d", teo.first, teo.second);
  37.    
  38.     //STRING
  39.    
  40.     string vj;
  41.     cin >> vj
  42.    
  43.     return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment