Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #define NEDELI 4
- #define DENOVI 5
- // ovde strukturata RabotnaNedela
- struct RabotnaNedela {
- int casovi[DENOVI];
- };
- typedef struct RabotnaNedela RN;
- // ovde strukturata Rabotnik
- struct Rabotnik {
- char ime[50];
- RN nedeli[NEDELI];
- };
- typedef struct Rabotnik R;
- // ovde funkciite
- void table(R* r, int n) {
- int i,j,z;
- printf("Rab\t1\t2\t3\t4\tVkupno\n");
- for(i = 0; i < n; ++i) {
- printf("%s\t", r[i].ime);
- int vkupno_site_nedeli = 0;
- for(j = 0; j < NEDELI; ++j) {
- int za_edna_nedela_vkupno = 0;
- for(z = 0; z < DENOVI; ++z) {
- za_edna_nedela_vkupno += r[i].nedeli[j].casovi[z];
- }
- vkupno_site_nedeli += za_edna_nedela_vkupno;
- printf("%d\t", za_edna_nedela_vkupno);
- }
- printf("%d\n", vkupno_site_nedeli);
- }
- }
- int maxNedela(R* rabotnik) {
- int i, j, max = 0, ned;
- for(i = 0; i < NEDELI; ++i) {
- int temp_max = 0;
- for(j = 0; j < DENOVI; ++j) {
- temp_max += (*rabotnik).nedeli[i].casovi[j];
- }
- if(temp_max > max) {
- max = temp_max;
- ned = i;
- }
- }
- return ned+1;
- }
- int main() {
- int n;
- scanf("%d", &n);
- R rabotnici[n];
- int i;
- for (i = 0; i < n; ++i) {
- scanf("%s", rabotnici[i].ime);
- int j;
- for (j = 0; j < NEDELI; ++j) {
- int k;
- for (k = 0; k < DENOVI; ++k) {
- scanf("%d", &rabotnici[i].nedeli[j].casovi[k]);
- }
- }
- }
- printf("TABLE\n");
- table(rabotnici, n);
- printf("MAX NEDELA NA RABOTNIK: %s\n", rabotnici[n / 2].ime);
- printf("%d\n", maxNedela(&rabotnici[n / 2]));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement