Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #include <iostream>
- using namespace std;
- #define NMAX 100
- #define INFILE "NUMERE.IN"
- int v[NMAX]= {0,1,2,3,4,5,6,7};
- int n=8;
- void sterge(int v[], int& n, int i, int j)
- {
- int dif = j - i + 1;
- j++;
- while (i < n - dif)
- {
- v[i] = v[j];
- i++;
- j++;
- }
- n -= dif;
- }
- void citire(int& n, int v[])
- {
- ifstream fin(INFILE);
- fin >> n;
- for (int i = 0; i < n; i++)
- fin >>v[i];
- }
- int main()
- {
- citire(n, v);
- for (int i = 0; i < n - 1; i++)
- {
- int j;
- for (j = i + 1; j < n; j++)
- if (v[i] != v[j])
- break;
- if (j - 1 != i)
- sterge(v, n, i + 1, j - 1);
- }
- for (int i = 0; i < n; i++)
- cout << v[i] << ' ';
- return 0;
- }
Add Comment
Please, Sign In to add comment