请大家帮 看看 谢谢
c代码
-----------
#include <stdio.h>
#include <string.h>
int main()
{
char* PI = "31415926535897932384";//20位
char szUserName[80];
int nLen;
int i;
char c;
do
{
printf("请输入用户名:");
scanf("%s", szUserName);//赋值到SZUSERNAME数组
nLen = strlen(szUserName);//得到NAME的输入长度
if (nLen >= 5 && nLen <= 0x14) break;//如果长度大于等于5和小于等于16调处循环
} while(true);
printf("注册码:");//输出注册码
for (i = 0; i < nLen; i++)//注册码 运算//I=0,I《注册名的长度就继续
{
c = szUserName[i] % PI[i];//数组的第一位跟PI的第一位求余放到c中
c <<= 1;//c左移1位
if (c > 'z') c = 0x1a;//判断如果c大于"z"则c=0xa
if (c < 'A') c = 0x82 - c;//判断如果c小于"A"则c=0x82-c
if (c > 'A' && c < 'a') c = c % 0xA + 0x30;//判断如果c同时大于"A"小于"a"则c=c跟0xA求余加上0x30
printf("%c", c);//输出c
}
printf("\n");
}
---------------------
下面是我的delphi代码
--------------
procedure TForm1.Button1Click(Sender: TObject);
var
//const pi=31415926535897932384;
pi:ansistring;szname:ansistring;
i:integer;
c,cd,nlen:variant;begin
{usp:='1234567890';
asp:=copy(usp,1,1);
Edit1.Text:=asp;
end;}
pi:='31415926535897932384';
szname:=Edit1.text;
nlen:=length(szname);
showmessage(nlen);
if nlen >= 5 and nlen <= 14 then
showmessage("长度大于等于5和小于等于16了!");
else
for i:=0 to i < nlen do
begin
c:=copy(szname,i,1) mod copy(pi,i,1);
c:=c shl 1;
if c> 'z' then c:=$1a;
if c< 'A' then c:=$82-c;
if c> 'A' and c< 'a' then c:= c mod $A + $30;
cd:=cd+c;
end;end.
----
我在按F9的时候delphi提示这个错误
[错误] Unit1.pas(46): Incompatible types//也就是
(if nlen >= 5 and nlen <= 14 then)这行我不知道怎么搞 汗啊``小弟刚入门请求大哥们帮忙
再次谢谢
c代码
-----------
#include <stdio.h>
#include <string.h>
int main()
{
char* PI = "31415926535897932384";//20位
char szUserName[80];
int nLen;
int i;
char c;
do
{
printf("请输入用户名:");
scanf("%s", szUserName);//赋值到SZUSERNAME数组
nLen = strlen(szUserName);//得到NAME的输入长度
if (nLen >= 5 && nLen <= 0x14) break;//如果长度大于等于5和小于等于16调处循环
} while(true);
printf("注册码:");//输出注册码
for (i = 0; i < nLen; i++)//注册码 运算//I=0,I《注册名的长度就继续
{
c = szUserName[i] % PI[i];//数组的第一位跟PI的第一位求余放到c中
c <<= 1;//c左移1位
if (c > 'z') c = 0x1a;//判断如果c大于"z"则c=0xa
if (c < 'A') c = 0x82 - c;//判断如果c小于"A"则c=0x82-c
if (c > 'A' && c < 'a') c = c % 0xA + 0x30;//判断如果c同时大于"A"小于"a"则c=c跟0xA求余加上0x30
printf("%c", c);//输出c
}
printf("\n");
}
---------------------
下面是我的delphi代码
--------------
procedure TForm1.Button1Click(Sender: TObject);
var
//const pi=31415926535897932384;
pi:ansistring;szname:ansistring;
i:integer;
c,cd,nlen:variant;begin
{usp:='1234567890';
asp:=copy(usp,1,1);
Edit1.Text:=asp;
end;}
pi:='31415926535897932384';
szname:=Edit1.text;
nlen:=length(szname);
showmessage(nlen);
if nlen >= 5 and nlen <= 14 then
showmessage("长度大于等于5和小于等于16了!");
else
for i:=0 to i < nlen do
begin
c:=copy(szname,i,1) mod copy(pi,i,1);
c:=c shl 1;
if c> 'z' then c:=$1a;
if c< 'A' then c:=$82-c;
if c> 'A' and c< 'a' then c:= c mod $A + $30;
cd:=cd+c;
end;end.
----
我在按F9的时候delphi提示这个错误
[错误] Unit1.pas(46): Incompatible types//也就是
(if nlen >= 5 and nlen <= 14 then)这行我不知道怎么搞 汗啊``小弟刚入门请求大哥们帮忙
再次谢谢
解决方案 »
- Delphi 如何根据汉字获取拼音首字母(考虑多音字和生僻字)
- 为什么报这个错??Undeclared identifier: 'SaveDialog1'
- 报表打印问题
- 散分
- 请问各位高手自定义消息的ID号 是怎样与消息的数据结构关联在一起的呢
- 请问,这样的函数怎么调用???在线等。
- 关于DBGRID录入的问题?
- 请问:if (StrLen(PChar(HWSHOPDATA)) <> 3) then HWSHOPDATA:='';是什么意思?
- 在不同的分分辨率下字体不受影响!
- 我要做毕业设计,请有经验的高手们进来看看!
- 请问当鼠标移动到ListView的某个项目上时(未点击)会触发什么事件吗?
- [高分求]如何调用微软拼音输入法2003这个版本
嘎嘎 SORRY啊 大家看起来可能 很不容易
在Delphi中,if后面的变量,如果有大量的布尔型操作,则and、or之类必须用“()“分开