Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //1.zad 1 grupa II termin 2019
- #include <stdio.h>
- #include <ctype.h>
- #include <string.h>
- int funkcija(int *niza, int n) {
- int brojac = 0;
- int izbrisani[n]; // 0 znaci ne e izbrisan, 1 deka e izbrisan
- for(int i = 0; i < n; i++) {
- izbrisani[i] = 0;
- }
- for(int i = 0; i < n; i++) {
- if(niza[i] > 0 && izbrisani[i] == 0) {
- for(int j = 0; j < n; j++) {
- if(niza[j] == (-niza[i]) && izbrisani[j] == 0) {
- brojac += 2;
- izbrisani[i] = 1;
- izbrisani[j] = 1;
- }
- }
- }
- }
- for(int i = 0; i < n; i++) {
- if(izbrisani[i] == 0) {
- printf("%d ", niza[i]);
- }
- }
- printf("\n");
- return brojac;
- }
- int main(){
- int n;
- scanf("%d", &n);
- int niza[n];
- for(int i = 0; i < n; i++) {
- scanf("%d", &niza[i]);
- }
- printf("%d\n", funkcija(niza, n));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement