Advertisement
Josif_tepe

Untitled

Dec 24th, 2020
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.39 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <ctype.h>
  5.  
  6. int vrati_dali_se_isti_dva_string(char *a, char *b) {
  7.     int n = strlen(a);
  8.     int m = strlen(b);
  9.     if(n != m) {
  10.         return -1;
  11.     }
  12.     for(int i = 0; i < n; i++) {
  13.         if(a[i] != b[i]) {
  14.             return -1;
  15.         }
  16.     }
  17.     return 0; // 0 znaci deka se isti
  18. }
  19. int main()
  20. {
  21.     FILE *f = fopen("in.txt", "r"); // treba da zememe podatoci od eden file
  22.     int poceten_broj;
  23.     fscanf(f, "%d", &poceten_broj);
  24.     char niza[10];
  25.     int tip;
  26.     float koeficient;
  27.     float najgolem_koeficient = -99999.0; // mnogu mal broj
  28.     int najgolem_tip = 99999.0;
  29.     char najgolem_klub[10];
  30.     float proizvod_na_koeficienti = 1.0;
  31.     while(1) { // dodeka raboti programata
  32.         fscanf(f, "%s", niza);
  33.         if(strcmp(niza, "#") == 0) {// ako nizata e ednakva na #, zavrsi go while loopot
  34.             break;
  35.         }
  36.         fscanf(f, "%d", &tip);
  37.         fscanf(f, "%f", &koeficient);
  38.         if(koeficient > najgolem_koeficient) {
  39.             najgolem_koeficient = koeficient;
  40.             najgolem_tip = tip;
  41.             strcpy(najgolem_klub, niza);
  42.         }
  43.         proizvod_na_koeficienti *= koeficient;
  44.     }
  45.     printf("%s %d %.2f\n", najgolem_klub, najgolem_tip, najgolem_koeficient);
  46.     printf("%.2f\n", proizvod_na_koeficienti * poceten_broj);
  47.    
  48.     return 0;
  49. }
  50.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement