c语言修改密码
发布时间: 2025-02-24 19:57:13
⑴ 用c语言或者其他语言编写替代密码和置换密码
给你,自己再稍微改造一下吧:
#include "stdio.h"
#include "conio.h"
main()
{
int k,i=0;
char a[100],b[100];
printf("qing shu ru ni de mi wen \n");
gets(a);
printf("qing shu ru mi shi \n");
scanf("%d",&k);
printf("\n");
do{
b[i]=(char)(a[i]+k);
if(b[i]>122){
b[i]=(char)(b[i]-26);
}
i++;
}while(a[i]!='\0');
puts(b);
getch();
}
⑵ c语言 替换 简易密码代换
#include <stdio.h>
void main()
{
int i=0, j=0;
char a[100] = {0};
scanf("%s",a);
while ('\0' != a[i])
{
a[i] += 4;
if (a[i] > 'z')
{
a[i] -= 26;
}
else if (a[i] > 'Z' && a[i] < 'e')
{
a[i] -= 26;
}
++i;
}
printf("%s",a);
}
验证无问题
⑶ c语言 修改密码初始密码为123456,密码包含数字和字母,数字必须大于2位
#include<stdio.h>
#include<string.h>
#include<ctype.h>
intmain()
{charpsw[21]="123456",t1[21],t2[21];
inti,n=0;
printf("请输入初始密码: ");
do
{gets(t1);
n++;
err=strcmp(t1,psw);
if(err)printf("初始密码错误!请重新输入! ");
}
while(err&&n<3);
if(strcmp(t1,psw))
{printf("密码错误,不能登录! ");
return0;
}
while(n<3)
{while(n<3)
{printf("请输入新密码: ");
gets(t1);
for(i=0;t1[i];i++)
if(isdigit(t1[i]))n++;
if(n<3)
{n=0;
printf("数字必须大于2位! ");
}
}
printf("请再次输入新密码: ");
gets(t2);
if(strcmp(t1,t2)==0)
printf("密码修改成功! ");
else
{printf("二次密码不一致! ");
n=0;
}
}
return0;
}
热点内容