導航:首頁 > 文檔加密 > c語言輸入一個字母加密

c語言輸入一個字母加密

發布時間:2023-08-26 08:31:52

A. c語言如何字母加密

//參考如下:

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

#include<stdio.h>

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

B. 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之間的任意一位數)

C. C語言將小寫字母加密

#include<stdio.h>

int main()

{

char s[100];

int i;

gets(s);

for(i=0;s[i];i++)

if (s[i]>='a'&&s[i]<='z')

{

s[i]+=2;

if(s[i]>'z')s[i]-=26;

}

puts(s);

system("pause");

return 0;

}

D. c語言字母加密

按照你的要求編寫的字母加密的C語言程序如下

(姓字母向後移兩位,名字母向後移三位)

#include<stdio.h>

#include<string.h>

int main(){

char src[30],result[]="",ch[2]={''};

int i,j,len;

fgets(src,30,stdin);

len=strlen(src);

for(i=0;src[i]!=' ';i++){

if('a'<=src[i] && src[i]<='z'){

ch[0]=(char)(((src[i]-'a')+2)%26+'a');

strcat(result,ch);

}else if('A'<=src[i] && src[i]<='Z'){

ch[0]=(char)(((src[i]-'A')+2)%26+'A');

strcat(result,ch);

}else{

ch[0]=src[i];

strcat(result,ch);

}

}

for(j=i;j<len;j++){

if('a'<=src[j] && src[j]<='z'){

ch[0]=(char)(((src[j]-'a')+3)%26+'a');

strcat(result,ch);

}else if('A'<=src[j] && src[j]<='Z'){

ch[0]=(char)(((src[j]-'A')+3)%26+'A');

strcat(result,ch);

}else{

ch[0]=src[j];

strcat(result,ch);

}

}

printf("%s ",result);

return 0;

}

E. C語言對字元進行加密

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

F. C語言指針:編寫程序,對輸入的一行小寫字母進行加密處理。

void encrypt(char *s)
{
while(*s)
{
if(*s>='a'&&*s<='z')
*s=(*s+1-'a')%26+'a';
s++;
}
}

#include<stdio.h>

int main()
{
char s[128];
printf("請輸入一個字元串:");
scanf("%s",s);
encrypt(s);
printf("加密後:%s\n",s);
return 0;
}

G. 用C語言加密 字母信息加密字母按字母表,進行對調,大小寫不變(a-z,b-y,c-x,…) 急求答案!

//VC++6.0下進行編譯
#include <stdio.h>
#define N 25

void jiami(char namea[256])
{
FILE *fp_jiami,*fp_file2;
char c;
fp_jiami=fopen(namea,"rb");
fp_file2=fopen("file2.plg","wb");
while(EOF!=(fscanf(fp_jiami,"%c",&c)))
{
if((c>='A'&&c<='Z')||(c>='a'&&c<='z'))
{
c=c+N;
if (!((c>='A'&&c<='Z')||(c>='a'&&c<='z')))c=c-26;
if(c>='a'&&c<='z')c=c-32;
}
fprintf(fp_file2,"%c",c);
}
fclose(fp_file2);
fclose(fp_jiami);
}

void jiemi(char en_name[256])
{
FILE *fp_jiemi,*fp_file3;
char c;
fp_jiemi=fopen(en_name,"rb");
fp_file3=fopen("file3.plg","wb");
while(EOF!=(fscanf(fp_jiemi,"%c",&c)))
{
if((c>='A'&&c<='Z')||(c>='a'&&c<='z'))
{
c=c-N;
if (!((c>='A'&&c<='Z')||(c>='a'&&c<='z')))c=c+26;
if(c>='A'&&c<='Z')c=c+32;
}

fprintf(fp_file3,"%c",c);
}
fclose(fp_file3);
fclose(fp_jiemi);

}

int main()
{
char name[256];
int n;

printf("輸入你要操作的TXT文本:");
gets(name);

printf("\n請選擇需要進行的操作:\n");
printf(" 1:加密 2:解密 \n");
printf("輸入你的選擇:");

scanf("%d",&n);
switch(n) {
case 1:{jiami(name);printf("\t加密成功!!\n\n");
break;}
case 2:{jiemi(name);printf("\t解密成功!!\n\n");
break;}
default:{printf("輸入操作不存在!");}
}

return 0;

}

H. C語言題編程實現對鍵盤輸入的大寫英文字母進行加密。字母

#include<stdio.h>
#include<ctype.h>
intmain()
{inti;
chars[200];
gets(s);
for(i=0;s[i];i++)
if(isalpha(s[i]))
{s[i]+=3;
if(s[i]%0x20>26)s[i]-=26;
}
puts(s);
return0;
}

I. C語言編程問題:從鍵盤上輸入一個字元串按照以下規則對其加密。

#include<stdio.h>

#include<string.h>

intmain(){

inti;

chars[80];

printf("請輸入字元串:");

while(scanf("%s",s)==1)

{

printf("加密前:%s ",s);

i=0;//i定義在此處便於第二次運行

while(s[i])

{if(s[i]>='A'&&s[i]<='Z')

s[i]=(s[i]-'A'+3)%26+'A';

elseif(s[i]>='a'&&s[i]<='z')

s[i]=(s[i]-'a'+3)%26+'a';

++i;}

printf("加密後:%s ",s);

printf("請輸入字元串[<Ctrl+Z><ENTER>結束程序]:");

}

return0;

}

閱讀全文

與c語言輸入一個字母加密相關的資料

熱點內容
平安經營貸結清後如何解壓 瀏覽:938
蘋果系統的解壓縮軟體 瀏覽:856
python火鍋店運營分析 瀏覽:985
c語言編譯器手機在線 瀏覽:848
戰艦世界什麼伺服器地址 瀏覽:550
windowsphone解壓縮 瀏覽:646
android工程目錄結構 瀏覽:137
pdf文檔是反的 瀏覽:528
javaobject比較 瀏覽:867
安卓如何設置微信屏幕鎖 瀏覽:189
本溪雲伺服器 瀏覽:375
玩機技巧華為app如何了解純凈模式 瀏覽:905
換演算法則數不變 瀏覽:719
java工作流activiti 瀏覽:788
單片機自動門程序 瀏覽:423
java培訓長沙 瀏覽:494
程序員生存現狀 瀏覽:588
光環游戲安裝器在哪個文件夾 瀏覽:654
公眾號圖片被壓縮 瀏覽:291
github優秀java 瀏覽:594