大家看看,这个程序是打印译密码,为什么输不出来,大家帮忙看看
#include <stdio.h>void main()
{char c1;
while ((c1=getchar())!='\n')
{if ((c1>='a'&& c1<='z')||(c1>='A' && c1<='Z'))
c1=c1+4;
if (c1>'Z' && c1<='Z'+4|| c1>'z')
c1=c1-26;
}
printf("%c",c1);
}
大家看看,这个程序是打印译密码,为什么输不出来,大家帮忙看看 把代码写成这样以后,你发现问题了吗?
这个是对一串字符进行加密的程序,不知道是不是楼主想要的效果
本帖最后由 755708445 于 2017-4-24 21:06 编辑楼主是想写一个字符串加密程序吗?
#include<stdio.h>
#define MAX_SIZE 20
int main(void)
{
char c1;
int count=0;
char passwords;
while((c1=getchar())!='\n')
{
if ((c1>='a'&& c1<='z')||(c1>='A' && c1<='Z'))
c1=c1+4;
if (c1>'z'||c1<'a'||c1>'Z'||c1<'A')
c1=c1-26;
if(count>MAX_SIZE-1)
{
puts("密码超长!");
break;
}
passwords=c1;
count++;
}
passwords='\0';
printf("加密后的字符串:%s",passwords);
return 0;
}
755708445 发表于 2017-4-24 09:32
楼主是想写一个字符串加密程序吗?
为什么我的那个不行
人造人 发表于 2017-4-23 14:09
把代码写成这样以后,你发现问题了吗?
这样好像不行,为什么不行啊,解释一下
人造人 发表于 2017-4-23 14:09
把代码写成这样以后,你发现问题了吗?
好像有问题,你觉得用这个能写出来吗,你试试,帮帮忙 djdj 发表于 2017-4-25 22:47
好像有问题,你觉得用这个能写出来吗,你试试,帮帮忙
#include <stdio.h>
int main(void)
{
char c1;
while((c1 = getchar()) != '\n')
{
if((c1 >= 'a' && c1 <= 'z') || (c1 >= 'A' && c1 <= 'Z'))
c1 = c1 + 4;
if(c1 > 'Z' && c1 <= 'Z' + 4 || c1>'z')
c1 = c1 - 26;
printf("%c", c1);
}
//printf("%c", c1);
return 0;
}
asdfghjkl
ewhjklnop请按任意键继续. . .
页:
[1]