Advertisement
sellmmaahh

OR-struktura1

Sep 5th, 2015
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.72 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. struct Kompleksni {
  5. double Re, Im;
  6. };
  7.  
  8. int Izbaci (struct Kompleksni *niz, int vel)
  9. {
  10.     int i,j, velicina=vel;
  11.     for (i=0; i<velicina; i++) {
  12.             if (niz[i].Re>0 && niz[i].Im>0) {
  13.                     for (j=i; j<velicina; j++) {
  14.                             niz[j]=niz[j+1];
  15.                     }
  16.                     velicina--;
  17.                     i--;
  18.             }
  19.     }
  20.     return velicina;
  21. }
  22.  
  23.  
  24. int main () {
  25.     struct Kompleksni niz[5]={{2,1},{-1,2},{-1,-1},{6,7},{7,-1}};
  26.     int nv=Izbaci(niz,5);
  27.     int i;
  28.     printf("Novi niz: \n");
  29.     for (i=0; i<nv; i++) {
  30.             printf("%.2f, %.2f \n", niz[i].Re, niz[i].Im);
  31.     }
  32.  
  33.     return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement