StoneHaos

103

Nov 2nd, 2019
152
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //103
  2. #include <cstdio>
  3. #define form(i, n) for (int i = 0; i < (n); ++ i)
  4.  
  5. int main(void) {
  6.     FILE* fin = fopen("input.txt", "r");
  7.     FILE* fout = fopen("output.txt", "w");
  8.  
  9.     int p = 0, k = 0, s = 0, l = 0, f = 0;
  10.     char str[65];
  11.     fscanf(fin, "%s", str);
  12.     fclose(fin);
  13.     for (int i = 0; str[i] != 0; ++ i) {
  14.         if (str[i] == 'P') ++ p;
  15.         else if (str[i] == 'K') ++ k;
  16.         else if (str[i] == 'S') ++ s;
  17.         else if (str[i] == 'L') ++ l;
  18.         else if (str[i] == 'F') ++ f;
  19.     }
  20.     form(i, p) fprintf(fout, "P");
  21.     form(i, k) fprintf(fout, "K");
  22.     form(i, s) fprintf(fout, "S");
  23.     form(i, l) fprintf(fout, "L");
  24.     form(i, f) fprintf(fout, "F");
  25.     fprintf(fout, "\n");
  26.     fclose(fout);
  27.     return 0;
  28. }
RAW Paste Data