Fark Olusturma Example: 4.36 (Kriptoloji ile Gizlilik Zorlama)

Durum
Üzgünüz bu konu cevaplar için kapatılmıştır...
Üye
Katılım
1 Ocak 2021
Mesajlar
22
Tepki puanı
5
Yaş
32
5 HİZMET YILI
Fark Oluşturma 4.36 C++ ile Programlama Paul&Harvey Deitel

(Kriptoloji ile Gizlilik Zorlama) Uygulamanız kullanıcı tarafından girilen 4 basamaklı sayıyı okumalı ve şu şekilde şifrelemelidir;
- Her basamağa 7 ekledikten sonra ve yeni değeri 10 ile çarpmalı.
- Daha sonra ilk basamağı üçüncü ile, ikinci basamağı da dördüncü ile takas etmeli.
- Sonra şifreyi yazdırmalı.
- Şifrelenmis içeriği alan ve şifresini çözen (şifreleme düzenini tersine çevirecek) ayrı bir uygulama yazın.

Anonim - Önce meseleyi çözün. Sonra kodu yazın.

C++:
#ifndef _KRP_H_
#define _KRP_H_
#include <iostream>


class KRP {
protected: int index[4];
};

class SFRL: public KRP {
    int sayi;
public:
    explicit SFRL(int);
    void setSayi(int);
    int getSayi()const;
    int binler()const;
    int yuzler()const;
    int onlar()const;
    int birler()const;
    void ShowInfos()const;
    ~SFRL();
};

class SFRC: public KRP {
    int index0, index1, index2, index3;
public:
    explicit SFRC(int, int, int, int);
    void setIndex0(int);
    void setIndex1(int);
    void setIndex2(int);
    void setIndex3(int);
    int getIndex0()const;
    int getIndex1()const;
    int getIndex2()const;
    int getIndex3()const;
    void ShowInfos()const;
    ~SFRC();
};
#endif

Kod:
 = (birler() + 7) * 10;
index[1] = (onlar() + 7) * 10;
index[2] = (yuzler() + 7) * 10;
index[3] = (binler() + 7) * 10;
}
// SETTER - GETTER
void SFRL::setSayi(int s_a) { sayi = s_a; }
int SFRL::getSayi()const { return sayi; }
// BASAMAKLARINA AYIR
int SFRL::binler()const { return sayi / 1000; }
int SFRL::yuzler()const { return (sayi % 1000) / 100; }
int SFRL::onlar()const { return ((sayi % 1000) % 100) / 10; }
int SFRL::birler()const { return (((sayi % 1000) % 100) % 10) / 1; }
// YAZDIR
void SFRL::ShowInfos()const {
    std::cout << "------------------------------------";
    std::cout << std::endl;
    std::cout << "Girdiginiz Sayi:" << getSayi();
    std::cout << std::endl;
    std::cout << "Sifrelenmis Hali:" << index[2]<<"-"<< index[3]<<"-"<< index[0] <<"-"<< index[1];
    std::cout << std::endl;
    std::cout << "------------------------------------";
    std::cout << std::endl;
}
// YIKICI
SFRL::~SFRL() {
    sayi = NULL;
    index[0] = NULL; index[1] = NULL; index[2] = NULL; index[3] = NULL;
}
/*----------------------------------------------------------------------------------------*/

SFRC::SFRC(int ind0, int ind1, int ind2, int ind3) {
    setIndex0(ind0); setIndex1(ind1); setIndex2(ind2); setIndex3(ind3);
// ARREYE ATA
    index[0] = (getIndex0() / 10) - 7;
    index[1] = (getIndex1() / 10) - 7;
    index[2] = (getIndex2() / 10) - 7;
    index[3] = (getIndex3() / 10) - 7;
}
// SETTER - GETTER
void SFRC::setIndex0(int i_n0) { index0 = i_n0; }
void SFRC::setIndex1(int i_n1) { index1 = i_n1; }
void SFRC::setIndex2(int i_n2) { index2 = i_n2; }
void SFRC::setIndex3(int i_n3) { index3 = i_n3; }
int SFRC::getIndex0()const { return index0; }
int SFRC::getIndex1()const { return index1; }
int SFRC::getIndex2()const { return index2; }
int SFRC::getIndex3()const { return index3; }
// YAZDIR
void SFRC::ShowInfos()const {
    std::cout << "------------------------------------";
    std::cout << std::endl;
    std::cout << "Girilen Sifre:" << getIndex0() << "-" << getIndex1() << "-" << getIndex2() << "-" << getIndex3();
    std::cout << std::endl;
    std::cout << "Sifre cozumu:" << index[1] << index[0] << index[3] << index[2];
    std::cout << std::endl;
    std::cout << "------------------------------------";
    std::cout << std::endl;
}
// YIKICI
SFRC::~SFRC() {
    index0 = NULL; index1 = NULL; index2 = NULL; index3 = NULL;
    index[0] = NULL; index[1] = NULL; index[2] = NULL; index[3] = NULL;
}

C++:
#include <iostream>
#include "KRP.h"

int main() {
    int menu = NULL;
    int sayi = NULL;
    int index0 = NULL; int index1 = NULL; int index2 = NULL; int index3 = NULL;

    do {

        std::cout << "KRIPTOLOJI UYGULAMASI";
        std::cout << std::endl;
        std::cout << "------------------------------";
        std::cout << std::endl;
        std::cout << "1 - SIFRELE";
        std::cout << std::endl;
        std::cout << "2 - SIFRE COZ";
        std::cout << std::endl;
        std::cout << "3 - CIKIS";
        std::cout << std::endl;
        std::cout << "------------------------------";
        std::cout << std::endl;
        std::cout << "Seciminizi Yapiniz:";
        std::cin >> menu;

        if (menu == 1) {
       
            std::cout << "---------------------------";
            std::cout << std::endl;
            std::cout << "Dort Haneli Bir Sayi Giriniz:";
            std::cin >> sayi;
       
            SFRL Crp(sayi);
            Crp.ShowInfos();
            Crp.~SFRL();
        }
         if (menu == 2) {
       
            std::cout << "--------------------------";
            std::cout << std::endl;
            std::cout << "Sifrelenmis Sayilari Giriniz(her '-' icin enter basiniz. ):";
            std::cin >> index0 >> index1 >> index2 >> index3;
       
            SFRC Dcrp(index0, index1, index2, index3);
            Dcrp.ShowInfos();
            Dcrp.~SFRC();
        }
         if (menu == 3) {
            break;
         }


    } while (true);

    return 0;
}
 
Dünyalı dostum tam olarak anlamadın galiba
Emektar Üye
Katılım
11 Eki 2020
Mesajlar
1,736
Çözümler
106
Tepki puanı
418
Ödüller
8
Sosyal
5 HİZMET YILI
teşşekür ederim.
 
Durum
Üzgünüz bu konu cevaplar için kapatılmıştır...
Üst