几种不同的注册码比较算法

第一种方法:

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
void main()
{
    char user[100],password[100];
    int len1,len2;
    printf("请输入用户名:\t");
    scanf("%s",&user);
    len1=strlen(user);
    len1+=3;
    printf("请输入密码:\t");
    scanf("%s",&password);
    len2=strlen(password);
    len2-=2;
    if ((len1-len2)==0) 
    {
        printf("\n\n登陆成功\n\n");
        system("pause");
    }
    else 
    {
        printf("\n\n密码错误\n\n");
        system("pause");
    }
}

第二种方法:

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
void main()
{
    char user[100],password[100];
    char pass[100]={0};
    char pacc[]="NULL";
    char pasc[]="skhrbnc";
    printf("请输入用户名:\t");
    scanf("%s",&user);
    printf("请输入密码:\t");
    scanf("%s",&password);
    strcat(pass,pacc);
    strcat(pass,pasc);
    if (strcmp(pass,password)==0) 
    {
        printf("\n\n登陆成功\n\n");
        system("pause");
    }
    else 
    {
        printf("\n\n密码错误\n\n");
        system("pause");
    }
}

第三种方法:

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
void main()
{
    int i,n;
    char user[1000];
    int password;
    printf("用户名:");
    scanf("%s",user);
    printf("\n密  码:");
    scanf("%d",&password);
    if(strcmp(user,"admin")==0)
    {
        n=2;
        for(i=0;i<10;i++)
        {
            n*=2;
        }
        if((password-n)==0)
        {
            printf("\n\n登陆成功\n\n");
        }
        else printf("\n\n用户名或密码错误\n\n");
    }
    else printf("\n\n用户名或密码错误\n\n");
    system("pause");
}

第五种方法:

#include<stdio.h>
#include<string.h>

int main(void)
{
    char user[100];
    char mima[100];
    int i;
    int j;
    printf("请输入用户名:");
    scanf("%s",&user);
    printf("\n请输入密码:");
    scanf("%s",&mima);
    
    for(i=0;i<strlen(user);i++);
    {
        user[i]=(user[i]^3)+3;
    }
    for(j=0;j<strlen(mima);j++);
    {
        mima[j]=(mima[j]-4)^4;
    }
    

    if(strcmp(user,mima)==0)
    {
        printf("\n骚年你比蛙蛙萌多了哟\n");
    }
        else printf("\n骚年你没有蛙蛙萌哟\n");
    system("pause");
    return 0;
}

大家可以尝试着用其他的方法来写

转载于:https://www.cnblogs.com/D0g3/p/4162658.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值