Professional Documents
Culture Documents
Задачи 10
1. Пример за структури
#include <stdio.h>
#include <stdlib.h>
struct student{
char ime[15];
char prezime[15];
int index;
int vozrast;
float prosek;
};
int main(int argc, char *argv[])
{
struct student primer={"Goran","Noveski",8103,25,8.35};
printf("Ime: %s\n",primer.ime);
printf("Prezime: %s\n",primer.prezime);
printf("Indeks: %d\n",primer.index);
printf("Vozrast: %d\n",primer.vozrast);
printf("Prosek: %.2f\n",primer.prosek);
system("PAUSE");
return 0;
}
2. Креирање на структура датум и функција која за аргумент прима објект од структурата датум и
податочниот член godina го зголемува за 10.
#include <stdio.h>
#include <stdlib.h>
struct datum{
int den;
int mesec;
int godina;
};
denes=dodaj10(denes);
printf("Posle 10 godini ke bide:
%d.%d.%d\n",denes.den,denes.mesec,denes.godina);
system("PAUSE");
return 0;
}
#include <stdio.h>
#include <stdlib.h>
struct tocka{
float x;
float y;
};
#include <stdio.h>
#include <stdlib.h>
struct student{
char ime[15];
char prezime[15];
int poeni;
};
for(i=n-1;i>0;i--){
for(j=0;j<i;j++){
if(a[j].poeni<a[j+1].poeni){
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
for(i=0;i<n;i++){
printf("%s\t%s\t%d\n",a[i].ime,a[i].prezime,a[i].poeni);
if(a[i].poeni>50 && a[i+1].poeni<50){
printf("----------------------------------\n");
}
}
system("PAUSE");