求错在哪,要求加密matlab输出字符串,输入一串字符。

请编程将“China”译成密码,密码规律:用原来的字母后面的第四个字母代替原来的字母。完成后将程序通用化,任意输入五个字符,利用密码规律输出加密后的密码。
请编程将“China”译成密码,密码规律:用原来的字母后面的第四个字母代替原来的字母。完成后将程序通用化,任意输入五个字符,利用密码规律输出加密后的密码。
不区分大小写匿名
什么语言?
&如果是JAVA的话,记得JAVA有 unicode编码的,顺序为abc.......ABC.....然后只需要判断&获得unicode编码然后加四位,判断如果是Z,排在最后一位是不是不需要转换了。String str = "China";&&int z = (int) 'z';//z是最后的位置&&String str1 = "";&&for (int i = 0; i & str.length(); i++) {&&&char a = str.charAt(i);&&&if (a & z - 4) {&&&&a = (char) ((int) a + 4);&&&}&&&str1 +=&&}&&System.out.println(str1);得到的结果为 Glmre
#include#includeint main(){
char str[10];
gets(str);
int i,len=strlen(str);
for(i=0;i&i++)
str[i]=str[i]+4;
printf(&%s\n&,str);
return 0;}
( ?世纪初 )设计领域最重要的发展是适应现代世界的一种设计语汇的出现,这种语汇实质同现代世界的先进技术和技术所带来的新的生活方式有关。
#include&stdio.h& void main() { char a[5]; printf(&请输入5个字符\n&); for(i=0;i&5;i++) { scanf(&%c&,&a[i]); } printf(&加密后的密码是:\n&); for(i=0;i&5;i++) a[i]=a[i]+4; for(i=0;i&5;i++) printf(&%c &,a[i]); }
#include
#include
void main()
{
char a[6],
printf(&input the string\n&);
for(i=0;i&5;i++)
a[i]=a[i]+4;
printf(&您输入的密码密文为:&);
printf(&\n 是否显示明文密码?(y or n)\n&);
scanf(&%c&,&ch);
if(ch=='y')
printf(&明文密码为:&);
for(i=0;i&5;i++)
{printf(&%c&,a[i]-4);}
system(&pause&);
}
#includevoid main(){int i=0;char a[5],b[5];printf(&please input five worlds:&);if(a[i+4]!='/0'){ b[i]=a[i+4];i++;}else if(a[i]!='/0'){b[i]=a[i];i++;}for(i=0;i&5;i++)printf(&%c&,&a[i]);}
main() {char c1='C',c2='h',c3='i',c4='n',c5='a'; c1+=4; c2+=4; c3+=4; c4+=4; c5+=4; printf(&%c%c%c%c%c\n,&c1,c2,c3,c4,c5); }
这个很容易啊 。
#include
#include
string ser(string str)
{
string str2;
char *ch=new char[str.size()] ;
for(int i=0;i&str.size();++i)
ch[i]=str[i]+4;
str2.append(ch,str.size());
return str2;
}
int main()
{
getline(cin,str);
cout&&ser(str);
return 0;
}
#include&iostream&
#include&string&
string ser(string str)// 可以转换任意长度的字符串{&string str2;&char *ch=new char[str.size()] ;&for(int i=0;i&str.size();++i)&{&&& ch[i]=str[i]+4;
&}&str2.append(ch,str.size());&return str2;}int main(){
&&getline(cin,str);&cout&&ser(str);
return 0;
}&
&#include "stdio.h"#include "conio.h"void main(){&&& char dx(char a);&&& char Str[]="China";&&&&&&&&& printf("%s\n",&Str);&&& for(i=0;i&5;i++)&&& {&&&&& temp=Str[i];&&&&& Str[i]=dx(temp);&&& }&&& printf("%s",&Str);&&& getch();}char dx(char a){& char temp=a+4;& if(temp&'a'&&temp&'z')& {&&&& if(temp&'w')&&&& {&&&&&&&&&&&&& }&&&& else&&&& {&&&&&&&& return ((char)(((int)(temp))-((int)('z'))-1+(int)('a'))) ;&&&& }& }& if(temp&'A'&&temp&'Z')& {&&&&& if(temp&'W')&&&& {&&&&&&&&&&&&& }&&&& else&&&& {&&&&&&&& return ((char)(((int)(temp))-((int)('Z'))-1+(int)('A'))) ;&&&& }& }
& return(-1);}
判断表达式错了,下面是更正的:
#include "stdio.h"#include "conio.h"void main(){&&& char dx(char a);&&& char Str[]="Zhwyg";&&&&&&&&& printf("%s\n",&Str);&&& for(i=0;i&5;i++)&&& {&&&&& temp=Str[i];&&&&& Str[i]=dx(temp);&&& }&&& printf("%s",&Str);&&& getch();}char dx(char a){& char temp=a+4;& if(a&='a'&&a&='z')& {&&&& if(temp&'w')&&&& {&&&&&&&&&&&&& }&&&& else&&&& {&&&&&&&& return ((char)(((int)(temp))-((int)('z'))-1+(int)('a'))) ;&&&& }& }& if(a&='A'&&a&='Z')& {&&&&& if(a&'W')&&&& {&&&&&&&&&&&&& }&&&& else&&&& {&&&&&&&& return ((char)(((int)(temp))-((int)('Z'))-1+(int)('A'))) ;&&&& }& }
& return(-1);}
&#include "stdio.h"#include "conio.h"void main(){&&& char dx(char a);&&& char Str[]="Zhang";&&&&&&&&& printf("%s\n",&Str);&&& for(i=0;i&5;i++)&&& {&&&&& temp=Str[i];&&&&& Str[i]=dx(temp);&&& }&&& printf("%s",&Str);&&& getch();}char dx(char a){& char temp=a+4;& if(a&='a'&&a&='z')& {&&&& if(temp&'w')&&&& {&&&&&&&&&&&&& }&&&& else&&&& {&&&&&&&& return ((char)(((int)(temp))-((int)('z'))-1+(int)('a'))) ;&&&& }& }& if(a&='A'&&a&='Z')& {&&&&& if(a&'W')&&&& {&&&&&&&&&&&&& }&&&& else&&&& {&&&&&&&& return ((char)(((int)(temp))-((int)('Z'))-1+(int)('A'))) ;&&&& }& }
& return(-1);}
C语言 存数组直接挨个+4 大于等于W需要倒减
用原来的字母后面的第四个字母代替原来的字母 你能读的通???
代码就不写了,把思路说下:任意输入N个字符,判断字符串长度,再逐一读出每个字符的ASC码,+4后再还原成字符(要注意判断+4后如大于Z就要从A计数)
等待您来回答
编程领域专家39.3 编制程序,将输入的一行字符以加密的形式输出,然后将其解密 串序列与 Crypt_De algrithms
182万源代码下载-
&文件名称: 39.3
& & & & &&]
&&所属分类:
&&开发工具: Visual C++
&&文件大小: 1 KB
&&上传时间:
&&下载次数: 2
&&提 供 者:
&详细说明:编制程序,将输入的一行字符以加密的形式输出,然后将其解密,解密的字符串序列与输入的正文相比较,吻合时输出解密的正文,否则解密失败。
加密时,将每个字符的ascii码依次反复加上“4962873”中的数字,并在32(‘’)~122(‘z’)之间作模运算。解密与加密的顺序相反。例如输入正文 “the result of 3 and 2 is not 8” 结果为:
-Programming, the input line character output in an encrypted form, and then decrypted, the decrypted text sequence of characters compared with the input, output to decrypt the body of the agreement, otherwise the decryption failed. Encryption, ascii code of each character in turn repeatedly with &quot 4962873&quot
in the figures, and 32 (&#39 &#39 )~ 122 (&#39 z&#39 ) as a model between the operations. Decryption and encryption in reverse order. For example, enter the text &quot the result of 3 and 2 is not 8&quot
文件列表(点击判断是否您需要的文件,如果是垃圾请在下面评价投诉):
&&39.3.cpp
&相关搜索:
&输入关键字,在本站182万海量源码库中尽情搜索:求字符串加密算法
[问题点数:20分,结帖人harry960]
求字符串加密算法
[问题点数:20分,结帖人harry960]
不显示删除回复
显示所有回复
显示星级回复
显示得分回复
只显示楼主
相关帖子推荐:
本帖子已过去太久远了,不再提供回复功能。.net技术:关于文本框自动输入加密解密
[问题点数:40分]
.net技术:关于文本框自动输入加密解密
[问题点数:40分]
不显示删除回复
显示所有回复
显示星级回复
显示得分回复
只显示楼主
相关帖子推荐:
本帖子已过去太久远了,不再提供回复功能。所有回答(3)
相同的明文相同的密钥相同的加密算法怎么得到的密文就不同了?
园豆:1659
把代码贴出来吧.
园豆:2179
园豆:2179
园豆:2179
C#好像可以直接调用sql 的存储过程
sql 存储过程也可以直接调用类库函数
园豆:1142
&&&您需要以后才能回答,未注册用户请先。}

我要回帖

更多关于 java输出字符串 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信