Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Задача 1:
- -------------
- #include <stdio.h>
- #include <math.h>
- typedef struct tocka2D {
- double x;
- double y;
- } tocka2D ;
- typedef struct tocka3D
- {
- double x;
- double y;
- double z;
- } tocka3D;
- float rastojanie ( tocka2D t1 , tocka2D t2) {
- return sqrt (( t1.x - t2.x) * (t1.x - t2.x) + (t1.y - t2.y) * (t1.y - t2.y));
- }
- float rastojanie3D ( tocka3D t1 , tocka3D t2) {
- 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));
- }
- void ista_prava ( tocka2D t1 , tocka2D t2 , tocka2D t3) {
- if( (t2.y-t1.y)/(t2.x-t1.x) == (t3.y-t2.y)/(t3.x-t2.x) )
- printf("Tockite se na ista prava.");
- else
- printf("Tockite ne se na ista prava.");
- }
- int main () {
- tocka2D t1 = { 4.54 , -7.35 };
- tocka2D t2 = { -3.76 , 10.45 };
- printf (" Rastojanieto pomegu tockite t1 i t2 e: %.2f\n", rastojanie (t1 , t2));
- return 0;
- }
- Задача 2:
- --------------
- #include <stdio.h>
- int ccw(int a, int b, int c, int d, int e, int f){
- if (((f-b)*(c-a)) > ((d-b)*(e-a))) return 0;
- return 1;
- }
- int main() {
- int a,b,c,d,e,f,g,h;
- scanf("%d %d %d %d %d %d %d %d", &a, &b, &c, &d, &e, &f, &g, &h);
- if(ccw(a,b,e,f,g,h)==ccw(c,d,e,f,g,h)) printf("no");
- else if(ccw(a,b,c,d,e,f)==ccw(a,b,c,d,g,h)) printf("no");
- else printf("yes");
- return 0;
- }
- Задача 3:
- -------------
- #include<stdio.h>
- typedef struct proizvod
- {
- char ime[20];
- int cena;
- int kolicina;
- }proizvod;
- int main()
- {
- int i,n;
- proizvod p[20];
- printf("Broj na proizvodi\n");
- scanf("%d", &n);
- for(i=0;i<n;i++)
- {
- printf("Ime: ");
- scanf("%s", &p[i].ime);
- printf("Cena: ");
- scanf("%d", &p[i].cena);
- printf("Kolicina: ");
- scanf("%d", &p[i].kolicina);
- }
- int vkupno=0;
- for(i=0;i<n;i++)
- {
- vkupno+=p[i].kolicina*p[i].cena;
- }
- printf("Vkupno: %d", vkupno);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement