一道C语言练习题

来源:百度知道 编辑:UC知道 时间:2024/05/23 02:18:41
任意输入一行电报文字,用条件编译方法编程实现以下功能:若需加密,则将字母后移6位,如“a“变为“g“,“u“变为“a“,数字也后移6位,如“0”变为“6”,“4”变为“0”,其他符号不变。若不需加密,则原文输出。

本人初学太菜了,编不出来

#include<stdlib.h>
#include<stdio.h>
#define SECRET 6;

void encode( char *p )
{
while (*p != '\0')
{
if (*p<'z' && *p>='a')
{
*p += SECRET;
if ( *p>'z' )
{
*p -= 26;
}
}
else if (*p=='z')
{
*p -= 20;
}
else if (*p<='Z' && *p>='A')
{
*p += SECRET;
if (*p>'Z')
{
*p -= 26;
}
}
else if (*p<='9' && *p>='0')
{
*p += SECRET;
if (*p>'9')
{
*p -= 10;
}
}

p++;
}
}

main()
{
char *Strings;
const char yOrn;

printf("\nDo you want ciphertext? y or n\n");
scanf( "%c", &yOrn);

printf("Please input your mes