GamerSK

fajnova sifra a desifra

Mar 14th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.46 KB | None | 0 0
  1. //---------------------------------------------------------------------------
  2.  
  3. #include <vcl.h>
  4. #include <fstream.h>
  5. #pragma hdrstop
  6.  
  7. #include "Unit1.h"
  8. //---------------------------------------------------------------------------
  9. #pragma package(smart_init)
  10. #pragma resource "*.dfm"
  11. TForm1 *Form1;
  12. AnsiChar c;
  13. //---------------------------------------------------------------------------
  14. __fastcall TForm1::TForm1(TComponent* Owner)
  15.     : TForm(Owner)
  16. {
  17. }
  18. //---------------------------------------------------------------------------
  19. void __fastcall TForm1::Button1Click(TObject *Sender) //Sifra
  20. {
  21.     Label1->Caption = "";
  22.     ofstream f; //Zapis
  23.     f.open("sifra.txt");
  24.     ifstream g; //Vypis
  25.     g.open("desifra.txt");
  26.     int i = 1;
  27.     if ( g.good() ) {
  28.         c = g.get() + i*i;
  29.         while ( g.good() ) {
  30.             f.put(c);
  31.             Label1->Caption = Label1->Caption + c;
  32.             i++;
  33.             c = g.get() + i*i;
  34.         }
  35.     }
  36.     f.close();
  37.     g.close();
  38. }
  39. //---------------------------------------------------------------------------
  40. void __fastcall TForm1::Button2Click(TObject *Sender) // Desifra
  41. {
  42.     Label2->Caption = "";
  43.     ifstream f; //Vypis
  44.     f.open("sifra.txt");
  45.     ofstream g; //Zapis
  46.     g.open("desifra.txt");
  47.     int i = 1;
  48.     if ( f.good() ) {
  49.         c = f.get() - i*i;
  50.         while ( f.good() ) {
  51.             g.put(c);
  52.             Label2->Caption = Label2->Caption + c;
  53.             i++;
  54.             c = f.get() - i*i;
  55.         }
  56.     }
  57.     f.close();
  58.     g.close();
  59. }
  60. //---------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment