Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ---3----
- #include<stdio.h>
- #include<stdlib.h>
- #include<string.h>
- typedef struct proizvod{
- char ime[100];
- int cena;
- int kol;
- } proi;
- int suma(int a,int b)
- {
- int vkup=0;
- int i=0;
- for(i=0;i<b;i++)
- {
- vkup+=a;
- }
- return vkup;
- }
- int main ()
- {
- proi proi[100];
- int n;
- int i;
- printf("Vnesete broj na proizvodi:");
- scanf("%d",&n);
- for(i=0;i<n;i++){
- printf("\nVnesete go imeto na proizvodot:");
- scanf("%s",&proi[i].ime);
- printf("\nVnesete ja cenata na proizvodot:");
- scanf("\n%d",&proi[i].cena);
- printf("\nVesete ja kolicinata na proizvodot:");
- scanf("\n%d",&proi[i].kol);
- }
- int cena=0;
- for(i=0;i<n;i++)
- {
- cena+=suma(proi[i].cena,proi[i].kol);
- }
- printf("\nCenata na vasata smetka e:%d",cena);
- return 0;
- }
- --------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;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement