This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Dec 23rd, 2012  |  syntax: None  |  size: 2.23 KB  |  views: 25  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #include <stdio.h>
  2.  
  3. struct Tacka {
  4.     int x,y;
  5. };
  6.  
  7. struct Trougao {
  8.     struct Tacka A,B,C;
  9. };
  10.  
  11. /*Korištena ideja iz knjige linearne algebre i geometrije BC''=AB''+AC''*/
  12. int IzbaciPravougle (struct Trougao niz[], int vel){
  13.     int i, j;
  14.     for(i=0; i<vel; i++){
  15.         if (
  16.             ((niz[i].B.x*niz[i].B.x)-niz[i].A.x && (niz[i].B.y*niz[i].B.y)-niz[i].A.y) /*AB NA KVADRAT*/
  17.             +
  18.             ((niz[i].C.x*niz[i].C.x)-niz[i].A.x && (niz[i].C.y*niz[i].C.y)-niz[i].A.y) /*AC NA KVADRAT*/
  19.             ==
  20.             ((niz[i].C.x*niz[i].C.x)-niz[i].B.x && (niz[i].C.y*niz[i].C.y)-niz[i].B.y) /*BC NA KVADRAT*/
  21.             ){
  22.         j=i;
  23.         while(j<vel-1){
  24.             niz[j]=niz[j+1];
  25.             j++;
  26.         }
  27.         vel--;
  28.         }
  29.     }
  30.     return vel;
  31. }
  32.  
  33.  
  34.  
  35. int main(){
  36.     struct Trougao Niz[50];
  37.     int i, vel, vel1;
  38.     printf("Unesite velicinu niza: ");
  39.     scanf("%d", &vel);
  40.     printf("Unesite elemente niza: \n");
  41.     i=0;
  42.     while(i < vel){
  43.         printf("Unesite x koordinatu tacke A %d. trougla: ", i+1);
  44.         scanf("%d", &Niz[i].A.x);
  45.         printf("Unesite y koordinatu tacke A %d. trougla: ", i+1);
  46.         scanf("%d", &Niz[i].A.y);
  47.         printf("Unesite x koordinatu tacke B %d. trougla: ", i+1);
  48.         scanf("%d", &Niz[i].B.x);
  49.         printf("Unesite y koordinatu tacke B %d. trougla: ", i+1);
  50.         scanf("%d", &Niz[i].B.y);
  51.         printf("Unesite x koordinatu tacke C %d. trougla: ", i+1);
  52.         scanf("%d", &Niz[i].C.x);
  53.         printf("Unesite y koordinatu tacke C %d. trougla: ", i+1);
  54.         scanf("%d", &Niz[i].C.y);
  55.         i++;
  56.     }
  57.     printf("Niz bez pravouglih trouglova glasi:\n");
  58.     vel1 = IzbaciPravougle(Niz, vel);
  59.     for(i=0; i<vel1; i++){
  60.         printf("\n x koordinata tacke A %d. trougla je %d,\n ", i+1, Niz[i].A.x);
  61.         printf("y koordinata tacke A %d. trougla je %d,\n ", i+1, Niz[i].A.y);
  62.         printf("x koordinata tacke B %d. trougla je %d,\n ", i+1, Niz[i].B.x);
  63.         printf("y koordinata tacke B %d. trougla je %d,\n ", i+1, Niz[i].B.y);
  64.         printf("x koordinata tacke C %d. trougla je %d,\n ", i+1, Niz[i].C.x);
  65.         printf("y koordinata tacke C %d. trougla je %d.\n ", i+1, Niz[i].C.y);
  66.     }
  67.     return 0;
  68. }
clone this paste RAW Paste Data