- UID
- 194217
- 在线时间
- 0 小时
- 最后登录
- 2018-11-15
- 注册时间
- 2012-8-17
- 宅魂
- 3068 点
- 贡献
- 5790 点
- 宅币
- 52958 枚
- 灵石
- 0 块
- 元气(技能点)
- 33 点
- 活跃
- 8 ℃
- 听众
- 12
- 收听
- 0
签到天数: 2 天 连续签到: 1 天 [LV.1]初来乍到
第四章
Forsaken
- 积分
- 81182
|
发表于 2012-8-18 11:20:40
|
显示全部楼层
会一点C语言和一点3dsmax可以么……
C语言自己写的一个程序:
/* 这是一段加密程序 */
#define N 100
#include <stdio.h>
#include <string.h>
struct student
{ char name[10];
char clas[20];
long num;
};
void f(char *a) /*加密:倒序+顺序*/
{
static int i=0,j=0;
char s[100],t[100];
char temp;
strcpy(s,a);
for(i=0,j=strlen(s)-1;j>i;i++,j--)
{
temp=s;
s=s[j];
s[j]=temp;
}
for(i=0;i<strlen(s);i++)
{
t=s;
}
t[strlen(s)]='\0';
for(i=0,j=strlen(s)-1;j>i;i++,j--)
{
temp=s;
s=s[j];
s[j]=temp;
}
strcat(t,s);
strcpy(a,t);
}
void cov(char *a,char *b,int k,int flag) /*加密:凯撒密码*/
{
char *p,*q;
int m;
for(p=a,q=b;*p;p++,q++)
{
if(*p>='A'&&*p<='Z') /* *p-[A,Z] */
{
if(flag)
{
if(*p+k>'Z')
*q=*p+k-'Z'+'A'-1;
else *q=*p+k;
}
else
{
if(*p+k<'A')
*q=(*p+k)+26;
else *q=*p+k;
}
}
else if(*p>='a'&&*p<='z') /* *p-[a,z] */
{
if(flag)
{
if(*p+k>'z')
*q=*p+k-'z'+'a'-1;
else *q=*p+k;
}
else
{
if(*p+k<'a')
*q=(*p+k)+26;
else *q=*p+k;
}
}
}
}
void main()
{
char a[N],b[N*2]="\0",c,m[N],n[N*2];
int k,flag,choice,i,p,q,count=0;
struct student maker={"ZQ","FC112",10111500};
printf("Simple Cryptography made by %s,class:%s,number:%ld\n",maker.name,maker.clas,maker.num);
printf("Please input the words to be converted:\n");
gets(a);
for(p=0;p<N;p++) m[p]=a[p];
for(q=0;q<N*2;q++) n[q]=b[q];
printf("The original words are:");
puts(a);
printf("Input any key to continue!\t press '5' to exit\n");
while(1)
{
count++;
for(i=0;i<80;i++) printf("-");
printf("Please input the way you want:\n choice:1(f) 2(cov) 3(f+cov) 4(cov+f)\nIf you want to leave,please input '5'\n");
scanf("%d",&choice);
if(choice==5) break;
if((choice!=1)&&(choice<=4&&choice>1))
{
printf("Please input the k(k(-C):\n");
scanf("%d",&k);
flag=k>=0?1:0;
system("cls");
printf("k=%d\nchoice=%d\noriginal words:",k,choice);
puts(a);
}
else
{
system("cls");
printf("choice=%d\ncount=%d\noriginal words:",choice,count);
puts(a);
}
printf("The concerted words are:");
switch(choice)
{
case 1:f(m);puts(m);break;
case 2:cov(m,n,k,flag);puts(n);break;
case 3:f(m);cov(m,n,k,flag);puts(n);break;
case 4:cov(m,n,k,flag);f(n);puts(n);break;
default:printf("Error!Please input choice(1-5):\n");
}
}
}
3dsmax:
|
评分
-
查看全部评分
|