學術休假-破譯密碼,學術休假破譯

來源:互聯網
上載者:User

學術休假-破譯密碼,學術休假破譯

蛋收到了兩串加密的密碼;破解的規則是:現將兩串密碼的數字提取出來,再將上下的數字進行相加,不夠的將用0代替,最後的數字再加上70得到字母的ASCII碼值,最後求出密碼。

例如:

範例輸入:

@#GHt1GG6gB70h)*4^2!*6

%G5=j6%Gg3$g6h0@

 

1 6 7 0 4 2 6

5 6 3 6 0

=============

6 12 10 6 4 2 6

範例輸出:

LRPLJHL

/* *Copyright (c) 2015,煙台大學電腦學院 *All gight reserved. *檔案名稱:temp.cpp *作者:邵帥 *完成時間:2015年1月18日 *版本號碼:v1.0*/#include<iostream>#include<cstdio>using namespace std;int main(){    int num1[81],num2[81],num3[81];//定義三個數字數組    char str1[81],str2[81];//定義兩個字串數組    int j1,j2,j3,i=0,swa;//swa用於將字元數組強制轉換成ASCII值    j1=j2=0;//初始化j1,j2    gets(str1);    gets(str2);//輸入字串!此處用到#include<cstdio>標頭檔    while (str1[i]!='\0')//字串的最後一個字元為'\0',此處用來判斷字元數組是否到達最後位置    {        swa=(int)str1[i];//強制轉換        if (swa>=48 && swa<=57)        {            num1[j1]=(swa-48);//數字數組內儲存篩選出來的數字,數字額ASCII碼值-48得到該數字          //  cout<<num1[j1]<<" ";測試資料用            j1++;        }        i++;    }    // cout<<endl;    i=0;//將i初始化    while (str2[i]!='\0')//同上    {        swa=(int)str2[i];        if (swa>=48 && swa<=57)        {            num2[j2]=swa-48;          //  cout<<num2[j2]<<" ";            j2++;        }        i++;    }    // cout<<endl;    if (j1>j2)//用於判斷兩個數字數組誰大誰小,小的將用0補充    {        for (j2+1; j2<j1; j2++)            num2[j2]=0;    }    if (j2>j1)    {        for (j1+1; j1<j2; j1++)            num1[j1]=0;    }   // cout<<"===================="<<endl;    for (j3=0; j3<j1; j3++)//將兩個數組的數字相加,得到最終的數組num3[]    {        num3[j3]=num1[j3]+num2[j3]+70;        cout<<(char)num3[j3];//強制轉換成字元    }}

運行結果:



@ Mayuko

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.