當前位置:首頁 » 編程語言 » c語言字母加密

c語言字母加密

發布時間: 2022-07-25 00:26:54

c語言怎麼加密字元

#include<stdio.h>
#include<string.h>
intmain()
{
charstr[]="00000",str2[]="00000",*p=str,*p2=str2;
printf("輸入5個字母:");
while(*p!=0)
{
scanf("%c",p);
if(*p==' ')
continue;
if(*p<'A'||(*p>'Z'&&*p<'a')||*p>'z')//輸入驗證,必須是字母
{
printf("只能輸入字母,請重新輸入 ");
p=str;
p2=str2;
fflush(stdin);//輸入有錯重新輸入前清空緩沖區。fflush屬於c擴展函數,正常使用沒問題,如需在linuxggc上使用,考慮多次調用getchar函數來清空
}
else
{
*p2=(*p)+4;
if(*p2>90&&*p2<97)//大寫字母加4,最大位不超出
*p2='A'+(*p2-90)-1;
if(*p2>122)//小寫字母加4,最大位不超出
*p2='a'+(*p2-122)-1;
p2++;
p++;
}
}

printf("原字元串為:%s 加密後的字元串為:%s ",str,str2);
return0;
}

㈡ C語言對字元進行加密

if(e>='A'&&e<='W')//
e+=3;
elseif(e>='X'&&e<='Z')
e-=23;
else
{
...//donotencryptordosomethingelse
}

㈢ c語言輸入一個字母咋樣給他加密輸出然後跳到這個字母的第五位呢

咨詢記錄 · 回答於2021-10-13

㈣ c語言如何字母加密

//參考如下:

//先輸入要加密的字母
//再輸入往後移動幾位的參數
//最後輸出加密後的字母
//絕對簡單,又符合要求int main()

#include<stdio.h>

{
char c;
scanf("%c",&c);
int a;
scanf("%d",&a);
printf("%c ",c+a);
return 0;
}

㈤ C語言簡單字母加密

#include <stdio.h>
int main()
{
char ch;
printf("Enter the char be encrypted\n");
cin>>ch;
char c=(ch-'A'+3)%26+'a';
printf("%c",c);
return 0;
}

㈥ c語言對大寫英文字母加密

#include <stdio.h>
#include <string.h>
int main()
{
char passwd[100],encrypted[100];
int i,j,k,t,move;
while(1)
{
printf("Enter message to be encrypted:");

gets(passwd);

move=3;
for(i=0; i<strlen(passwd); i++)
{
if(passwd[i] >= 'A' && passwd[i] <= 'Z')
{

passwd[i] = ((passwd[i]-'A')+move)%26+'A';

} else if(passwd[i] >= 'a' && passwd[i] <= 'z')
{

passwd[i] = ((passwd[i]-'a')+move)%26+'a';

}

}

printf("%s",passwd);

printf("\n");

}
return 0;
}
這道題實際上就是C語言版的凱撒加密(字母往後面移動1-25之間的任意一位數)

熱點內容
如何分辨一輛車是什麼配置 發布:2025-03-04 12:41:10 瀏覽:346
配置很低的電腦玩csgo怎麼調 發布:2025-03-04 12:40:29 瀏覽:22
視頻解析網站源碼 發布:2025-03-04 12:40:25 瀏覽:315
哪個軟體可以直接重啟安卓手機 發布:2025-03-04 12:22:42 瀏覽:608
c語言scanf的意思 發布:2025-03-04 12:08:31 瀏覽:467
兩端存儲器 發布:2025-03-04 12:07:49 瀏覽:85
安卓手機連不上無線網什麼原因 發布:2025-03-04 12:03:29 瀏覽:89
串口緩存區 發布:2025-03-04 11:59:12 瀏覽:579
php抓取鏈接 發布:2025-03-04 11:59:11 瀏覽:986
渦輪降溫用什麼伺服器 發布:2025-03-04 11:55:30 瀏覽:336