Advertisement
Pauleses

Untitled

Apr 10th, 2020
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. int n;
  8. string sakinys, simboliai, kodas[100];
  9. char raid, raide[100];
  10.  
  11. void Skaitymas()
  12. {
  13. ifstream fd1("Duomenys1.txt");
  14. getline(fd1, sakinys);
  15. ifstream fd2("Duomenys2.txt");
  16. fd2 >> n;
  17. fd2.ignore(100, '\n');
  18. for(int i = 0; i < n; i++){
  19. getline(fd2, simboliai);
  20. raide[i] = simboliai[0];
  21. kodas[i] = simboliai.substr(2);
  22. }
  23. }
  24. void Raides()
  25. {
  26. ofstream fr("Rezultatai.txt");
  27. for(int j = 0; j < n; j++){
  28. if(raid == ' '){
  29. fr << " "<<endl;
  30. break;
  31. }
  32. else if(raid == raide[j]){
  33. fr << kodas[j] << " ";
  34. }
  35. }
  36. }
  37. void Pavertimas()
  38. {
  39. for(int i = 0; i < sakinys.length(); i++){
  40. raid = sakinys[i];
  41. Raides();
  42. }
  43. }
  44. int main()
  45. {
  46. ofstream fr("Rezultatai.txt");
  47. Skaitymas();
  48. Pavertimas();
  49.  
  50. return 0;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement