Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include <ctype.h>
- int main() {
- int n;
- scanf("%d", &n);
- int niza[n];
- for(int i = 0; i < n; i++) {
- scanf("%d", &niza[i]);
- }
- int nova_niza[n];
- int m = 0;
- int se_pojavil;
- for(int i = 0; i < n; i++) {
- se_pojavil = 0;
- for(int k = 0; k < m; k++) {
- if(nova_niza[k] == niza[i]) {
- se_pojavil = 1;
- }
- }
- if(se_pojavil == 0) {
- nova_niza[m] = niza[i];
- m++;
- }
- }
- for(int i = 0; i < m; i++) {
- printf("%d ", nova_niza[i]);
- }
- }
- // 1 2 3 4 5
- // 1 3 6 10 15
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement