LoginSignup

This article is a Private article. Only a writer and users who know the URL can access it.
Please change open range to public in publish setting if you want to share this article with other users.

More than 3 years have passed since last update.

暗号化通信ゼミ 補足資料

Last updated at Posted at 2019-04-20

暗号化通信ゼミ

名前:****(ネット上に公開するため伏せます)

※この記事は限定公開で名前を記事内に記述している以上、本人である可能性が限りなく高いのが、もし確認する必要があるのであればコメントにて本人しか知りえない情報を確認してください。

[問1] ドイツ語判定プログラム

ソースコード

#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main(void) {
  string Farben[3] = {"Rot", "Orange", "Gelb"}; //ドイツ語
  string Crypto1 = "Red Orange Yellow";
  string Crypto2 = "Rot Orange Gelb";

  bool check = true; //ドイツ語かどうか判定する     
  Crypto1 += ' ';
  Crypto2 += ' '; //便利上末尾に空白を付ける

  vector<string> v;
  int i, j;

  // Crypto1バージョン
  for(i = 0; i < Crypto1.length() && Crypto1.length() > 0; i++) {
    if(Crypto1[i] == ' ') {
      v.push_back(Crypto1.substr(0, i)); //単語ごとに配列に格納 
      Crypto1 = Crypto1.substr(i + 1);
    }
  }
  for(i=0;i<v.size();i++){//単語ごとにドイツ語かどうか判定する 
    if(v[i]!=Farben[0]&&v[i]!=Farben[1]&&v[i]!=Farben[2]){
      check=false;
      break;
    }
  }
  if(check) cout<<"ドイツ語です"<<endl;
  else cout<<"ドイツ語ではありません"<<endl;

  v.clear();check=true;//初期設定 
  //Crypto2バージョン 
  for(i=0;i<Crypto2.length()&&Crypto2.length()>0;i++){
    if(Crypto2[i]==' '){
      v.push_back(Crypto2.substr(0,i));//単語ごとに配列に格納 
      Crypto2=Crypto2.substr(i+1);
    }
  }
  for(i = 0; i < v.size(); i++) {
    if(v[i] != Farben[0] && v[i] != Farben[1] && v[i] != Farben[2]) {
      check = false;
      break;
    }
  }
  if(check) cout << "ドイツ語です" << endl;
  else cout << "ドイツ語ではありません" << endl;
  return 0;
}

出力結果

ドイツ語ではありません
ドイツ語です

[3]cubing暗号の図

図1
1556251978282.jpg

図2
1556253369812.jpg

図3
1556252023146.jpg

図4
1556252053314.jpg

図5
1556252064695.jpg

0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up