Advertisement
dykow

Untitled

Apr 6th, 2018
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.92 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <cstdlib>
  4. #include <string.h>
  5.  
  6.  
  7. using namespace std;
  8.  
  9. int main()
  10. {
  11.     ifstream myfile("dane_6_3.txt");
  12.     if( !myfile.good() || !myfile.is_open() ){
  13.         cout << "Error!";    exit(0);
  14.     }
  15.  
  16.     string norm, encr, sub = 0;
  17.     ofstream yourfile("wyniki_6_3.txt");
  18.  
  19.     while (myfile >> norm && myfile >> encr){
  20.         for(int i=0; i < norm.length(); i++){
  21.             if((int)norm[i] > (int)encr[i]){
  22.                 if(i==0)    sub = (encr[i] - 65) + (90 - norm[i]);
  23.                 if(i>0 && ((encr[i] - 65) + (90 - norm[i]) != sub))
  24.  
  25.             }
  26.             else if ((int)norm[i] < (int)encr[i]){
  27.                 if(i==0)    sub = (encr[i] - norm[i]);
  28.                 if(i>0 && (encr[i] - norm[i]) != sub)
  29.                     {yourfile << norm << endl; break;}
  30.             }
  31.         }
  32.     }
  33.  
  34.     myfile.close();
  35.     yourfile.close();
  36.     return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement