Advertisement
NikJord

lab_1

Feb 19th, 2012
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.71 KB | None | 0 0
  1. ---3----
  2. #include<stdio.h>
  3. #include<stdlib.h>
  4. #include<string.h>
  5.  
  6. typedef struct proizvod{
  7.   char ime[100];
  8.   int cena;
  9.   int kol;
  10. } proi;
  11. int suma(int a,int b)
  12. {
  13.     int vkup=0;
  14.     int i=0;
  15.     for(i=0;i<b;i++)
  16.     {
  17.         vkup+=a;
  18.     }
  19.     return vkup;
  20. }
  21. int main ()
  22. {
  23.     proi proi[100];
  24.     int n;
  25.     int i;
  26.     printf("Vnesete broj na proizvodi:");
  27.     scanf("%d",&n);
  28.     for(i=0;i<n;i++){
  29.     printf("\nVnesete go imeto na proizvodot:");
  30.     scanf("%s",&proi[i].ime);
  31.     printf("\nVnesete ja cenata na proizvodot:");
  32.     scanf("\n%d",&proi[i].cena);
  33.     printf("\nVesete ja kolicinata na proizvodot:");
  34.     scanf("\n%d",&proi[i].kol);
  35.     }
  36.     int cena=0;
  37.     for(i=0;i<n;i++)
  38.     {
  39.     cena+=suma(proi[i].cena,proi[i].kol);
  40.     }
  41.     printf("\nCenata na vasata smetka e:%d",cena);
  42.  
  43.     return 0;
  44. }
  45.  
  46. --------1
  47.  
  48. #include <stdio.h>
  49.  #include <math.h>
  50.  
  51.  typedef struct tocka2D {
  52.  double x;
  53.  double y;
  54.  } tocka2D ;
  55.  
  56.  typedef struct tocka3D
  57.  {
  58.  double x;
  59.  double y;
  60.  double z;
  61.  } tocka3D;
  62.  
  63.  float rastojanie ( tocka2D t1 , tocka2D t2) {
  64.  return sqrt (( t1.x - t2.x) * (t1.x - t2.x) + (t1.y - t2.y) * (t1.y - t2.y));
  65.  }
  66.  
  67.  float rastojanie3D ( tocka3D t1 , tocka3D t2) {
  68.  
  69.  return sqrt (( t1.x - t2.x) * (t1.x - t2.x) + (t1.y - t2.y) * (t1.y - t2.y) + (t1.z - t2.z)*(t1.z - t2.z));
  70.  }
  71.  
  72.  void ista_prava ( tocka2D t1 , tocka2D t2 , tocka2D t3) {
  73.  if( (t2.y-t1.y)/(t2.x-t1.x) == (t3.y-t2.y)/(t3.x-t2.x) )
  74.  printf("Tockite se na ista prava.");
  75.  else
  76.  printf("Tockite ne se na ista prava.");
  77.  }
  78.  
  79.  int main () {
  80.  tocka2D t1 = { 4.54 , -7.35 };
  81.  tocka2D t2 = { -3.76 , 10.45 };
  82.  printf (" Rastojanieto pomegu tockite t1 i t2 e: %.2f\n", rastojanie (t1 , t2));
  83.  return 0;
  84.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement