Advertisement
Guest User

Untitled

a guest
Oct 24th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.42 KB | None | 0 0
  1. #include "iostream"
  2. #include "ConsolCyr.h"
  3. #include "cstdlib"
  4. #include "cmath"
  5. #include <string>
  6. //#include <stdafx>
  7. #include <fstream>
  8. using namespace std;
  9.  
  10. int codegive(int*, char*, int, int);
  11. void zero(int*, int);
  12. void codewright(int*, char*, int, int*);
  13. int main()
  14. {
  15.     const int NotUsed = system( "color 70" );
  16. char *s = new char[81];
  17. char *t = new char[10000];
  18. int *code = new int[256];
  19. int *stat= new int[256];
  20. int j=0;
  21. zero(code, 256);
  22. zero(stat, 256);
  23. do{ j=codegive(code, s , 81, j);}
  24. while(s[0]!='-');
  25. //for(int i=0; i<j-1; i++){cout << code[i] << ' '<< j<< endl;}
  26. codewright(code, s, j-2, stat);
  27.  
  28. system("pause");
  29. }
  30. void zero(int* arrayptr, int length){
  31.     for(int i=0; i<length; i++){
  32.         arrayptr[i]=0;
  33.     }}
  34. int codegive(int* arraycode, char* arrayptr, int length, int j){
  35.     ifstream fin("code.txt");
  36.     for(int i=0; i<length; i++){
  37.         //fin >> arrayptr[i];
  38.     //ifstream fin("code.txt",ios::in);
  39.     //fin >> arrayptr[i];
  40.     if(arrayptr[i]=='-'){break;}
  41.     arraycode[j]+=arrayptr[i];
  42.     if(arraycode[j]>256){arraycode[j]-=256;};
  43.     fin.close();
  44.     }
  45.     j++;
  46.    
  47.     return j;
  48.     }
  49. void codewright(int *arraycode, char* arrayptr, int j, int* stat){
  50.  int c=0;
  51.  int k=0;
  52.  do{
  53.  cin >> arrayptr[c];
  54.  if(k>j){k-=(j+1);};
  55.  arrayptr[c]+=arraycode[k];
  56.  if (arrayptr[c]>256){arrayptr[c]-=256;};
  57.  stat[arrayptr[c]]++;
  58.  cout << arrayptr[c];
  59.  if(arrayptr[c]=='\n'){cout << endl;};
  60.  k++;
  61.  c++;}
  62.  while(arrayptr[c]!='@');
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement