StoneHaos

test

Oct 30th, 2019
151
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //324 не полностью
  2. #include <cstdio>
  3.  
  4. int main(void) {
  5.     FILE* fin = fopen("input.txt", "r");
  6.     FILE* fout = fopen("output.txt", "w");
  7.  
  8.     int n, k, s = 0, m = 0;
  9.     fscanf(fin, "%d%d%*[\n]", &n, &k);
  10.     for (int i = 0; i < n; ++ i) {
  11.         int a;
  12.         char c;
  13.         fscanf(fin, "%c%*[^\n]%n%*c", &c, &a);
  14.         if (c == 'S') s += a * k;
  15.         else m += a * k;
  16.     }
  17.     fprintf(fout, "%.2f %.2f\n", s / 100.0, m / 100.0);
  18.     fclose(fin);
  19.     fclose(fout);
  20.     return 0;
  21. }
RAW Paste Data