c语言题目,希望大神给完整代码
答案:2 悬赏:60 手机版
解决时间 2021-04-01 09:50
- 提问者网友:藍了天白赴美
- 2021-04-01 02:12
c语言题目,希望大神给完整代码
最佳答案
- 五星知识达人网友:一秋
- 2021-04-01 03:31
#include
#include "string.h"
#include
int fun(char *);
int main()
{
char BUFF[17+1]="RUXENLYAXPAJVVRWP";
char TmpBUFF[17+1]="";
int offset=0;
int iRet=0;
for( offset=0;offset<=26;offset++ )
{
memset(TmpBUFF, 0x00, sizeof(TmpBUFF));
strcpy(TmpBUFF, BUFF);
for( int i=0;i<17;i++ )
{
TmpBUFF[i]=TmpBUFF[i]-offset;
if(TmpBUFF[i]<'A')
TmpBUFF[i]=TmpBUFF[i]+26;
}
if( !fun(TmpBUFF) )
{
printf( "包含LOVE的解码结果:[%s]偏移量[%d]
",TmpBUFF,offset );
}
}
return 0;
}
int fun( char *buff )
{
if( strstr(buff,"LOVE") )
{
return 0;
}
else
{
return -1;
}
}
#include "string.h"
#include
int fun(char *);
int main()
{
char BUFF[17+1]="RUXENLYAXPAJVVRWP";
char TmpBUFF[17+1]="";
int offset=0;
int iRet=0;
for( offset=0;offset<=26;offset++ )
{
memset(TmpBUFF, 0x00, sizeof(TmpBUFF));
strcpy(TmpBUFF, BUFF);
for( int i=0;i<17;i++ )
{
TmpBUFF[i]=TmpBUFF[i]-offset;
if(TmpBUFF[i]<'A')
TmpBUFF[i]=TmpBUFF[i]+26;
}
if( !fun(TmpBUFF) )
{
printf( "包含LOVE的解码结果:[%s]偏移量[%d]
",TmpBUFF,offset );
}
}
return 0;
}
int fun( char *buff )
{
if( strstr(buff,"LOVE") )
{
return 0;
}
else
{
return -1;
}
}
全部回答
- 1楼网友:夜余生
- 2021-04-01 04:22
//原文是:ILOVECPROGRAMMING
#include
#include
#include
void jiemi(char *miwen)
{
int i,j;
char *mingwen=(char*)malloc(strlen(miwen)+1);
mingwen[strlen(miwen)]='\0';
for(i=1;i<26;i++)
{
for(j=0;j {
mingwen[j]=miwen[j]-i>='A' ? miwen[j]-i : miwen[j]-i+26;
}
if(strstr(mingwen,"LOVE"))
{
printf("%s\n",mingwen);
break;
}
}
free(mingwen);
}
int main()
{
char miwen[]="RUXENLYAXPAJVVRWP";
jiemi(miwen);
return 0;
}
#include
#include
#include
void jiemi(char *miwen)
{
int i,j;
char *mingwen=(char*)malloc(strlen(miwen)+1);
mingwen[strlen(miwen)]='\0';
for(i=1;i<26;i++)
{
for(j=0;j
mingwen[j]=miwen[j]-i>='A' ? miwen[j]-i : miwen[j]-i+26;
}
if(strstr(mingwen,"LOVE"))
{
printf("%s\n",mingwen);
break;
}
}
free(mingwen);
}
int main()
{
char miwen[]="RUXENLYAXPAJVVRWP";
jiemi(miwen);
return 0;
}
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯