Advertisement
CosminVarlan

sir_fara_duplicate_pe_poz_consecutive

Mar 19th, 2020
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3.  
  4.  
  5. using namespace std;
  6.  
  7. ifstream fin("numere.in");
  8. ofstream fout("numere.out");
  9.  
  10. int n,k;
  11. int v[1000];
  12.  
  13. int main()
  14. {
  15.     fin >> n;
  16.     int poz=1;
  17.     fin>> v[0];
  18.     for(int i=1; i<n; i++)
  19.     {
  20.         fin >> k;
  21.         if ( k!= v[poz-1])
  22.         {
  23.             v[poz]=k;
  24.             poz++;
  25.         }
  26.     }
  27.     for(int i=0; i<poz; i++)
  28.         fout << v[i]<<' ';
  29.  
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement