Advertisement
Mentosan

Skema

Mar 30th, 2021
622
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.91 KB | None | 0 0
  1. #include <iostream>
  2. #include <string.h>
  3. #include <fstream>
  4.  
  5. using namespace std;
  6.  
  7. ifstream in("input.txt");
  8. ofstream out("output.txt");
  9.  
  10. int main() {
  11.     char sir[100];
  12.     in.get(sir, 100, '\n');
  13.     in.get();
  14.     out << '{' << endl;
  15.     while (!in.eof()) {
  16.         char vehName[20], vehHash[20];
  17.         char *cuvant = strtok(sir, " ");
  18.         bool ePrimu = true;
  19.         while (cuvant != NULL) {
  20.             if (ePrimu) {
  21.                 strcpy(vehName, cuvant);
  22.                 ePrimu = false;
  23.             } else {
  24.                 int l = strlen(cuvant);
  25.                 cuvant[l - 1] = '\0';
  26.                 strcpy(vehHash, cuvant);
  27.             }
  28.             cuvant = strtok(NULL, " ");
  29.         }
  30.         out << "\"" << vehHash << "\": \"" << vehName << "\"," << endl;
  31.         in.get(sir, 100, '\n');
  32.         in.get();
  33.     }
  34.     out << '}';
  35.     in.close();
  36.     out.close();
  37.     return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement