vb:肆旦裤
Function encode(ByVal s As String) As String
Const s1 = "efghijklmnopqrstuvwxyzabcdEFGHIJKLMNOPQRSTUVWXYZABCD"
Const s2 = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
Dim result As String
For i = 1 To Len(s)
If InStr(s2, Mid(Text1, i, 1)) = 0 Then
result = result & Mid(Text1, i, 1)
Else
result = result & Mid(s1, InStr(s2, Mid(Text1, i, 1)), 1)
End If
Next
encode = result
End Function
c++:
#include
using namespace std;
int main()
{
string encode(string s);
string line,line2;
getline(cin,line);
line2=encode(line);
cout<
};
string encode(string s)
{
char a,b;
for(string::size_type index=0;index!=s.size();++index)
{
a=s[index];
if(isalpha(a))
{
b=a+4;
if((b>迟棚90 && b<裂简97) ||(b>122))
b-=26;
}
else
b=a;
s[index]=b;
}
return s;
};
//看戚碧让了各位的回答顿时感觉c#果然很强大,写高局出来的代码最慧返清爽.
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace 加密
{
class Program
{
static void Main(string[] args)
{
string s = "dcbazyxwvutsrqponmlkjihgfedcbaDCBAZYXWVUTSRQPONMLKJIHGFEDCBA";
string s1 = Console.ReadLine();
foreach (char c in s1 )
{
try
{
Console.Write(s[s.LastIndexOf(c) - 4]);
}
catch
{
Console.Write(c);
}
}
Console.ReadLine();
}
}
}
#include <如兄stdio.h>
#include
#include
char *GenCode(char *s, char *code)
{
int i;
int len = strlen(s);
for(i=0; i
if(isalpha(*s)) *code++ = (*s++) + 4;
else *code++ = *s++;
}
return code-len;
}
int main()
{
char info[] = "卖孝Test Info...";
char buf[32] = "";
printf("%s\n", GenCode(info, buf));
return 0;
}
Delphi:
function encode(s:string):string;
var
i,j :integer;
t,l :string;
begin
l := '';
t := 'abcdefghijklmnopqrstuvwxyzabcdABCDEFGHIJKLMNOPQRSTUVWXYZABCD';
for i := 1 to length(s) do
begin
j := pos(s[i],t);
if j = 0 then
l := l + s[i]
else
l := l + t[j+4];
end;
result := l;
end;