Advertisement
Guest User

Untitled

a guest
Apr 25th, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. #include <iostream>
  2.  
  3.  
  4.  
  5. #include <fstream>
  6.  
  7.  
  8.  
  9. #include<cstring>
  10.  
  11.  
  12.  
  13. #include<cmath>
  14.  
  15.  
  16.  
  17. using namespace std;
  18.  
  19.  
  20.  
  21. void plot(int x, int a, char znak[], char znak2[], int klucz)
  22.  
  23. {
  24.  
  25. for(int i=1; i<x; i++)
  26.  
  27.  
  28.  
  29. {
  30.  
  31. if(klucz+a<x)
  32.  
  33. klucz=klucz+a;
  34.  
  35. else
  36.  
  37. klucz=klucz-x+a;
  38.  
  39. if(znak[klucz]==' ')
  40.  
  41. klucz++;
  42.  
  43. znak2[i]=znak[klucz];
  44.  
  45. znak[klucz]=' ';
  46.  
  47. }
  48.  
  49. }
  50.  
  51. int main()
  52.  
  53.  
  54.  
  55. {
  56.  
  57.  
  58.  
  59. char znak[1000];
  60.  
  61.  
  62.  
  63. char znak2[1000];
  64.  
  65.  
  66.  
  67. int a;
  68.  
  69.  
  70.  
  71. ifstream odczyt("plot.txt");
  72.  
  73.  
  74.  
  75. int x;
  76.  
  77.  
  78.  
  79. odczyt>>znak;
  80.  
  81.  
  82.  
  83. cout<<znak;
  84.  
  85.  
  86.  
  87. x=strlen(znak);
  88.  
  89.  
  90.  
  91. odczyt.close();
  92.  
  93.  
  94.  
  95. int klucz=0;
  96.  
  97. cout<<"\nPodaj klucz (ile wierszy): "<<endl;
  98.  
  99. cin>>a;
  100.  
  101. znak2[0]=znak[klucz];
  102.  
  103. znak[klucz]=' ';
  104.  
  105. plot(x, a, znak, znak2, klucz);
  106.  
  107. ofstream zapis("plot.txt");
  108.  
  109. for(int i=0; i<x; i++)
  110.  
  111. {cout<<znak2[i];
  112.  
  113. zapis<<znak2[i];
  114.  
  115. }
  116.  
  117. zapis.close();
  118.  
  119. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement