Several different algorithms for registration code comparison

Source: Internet
Author: User
Tags strcmp

The first method:

#include <stdio.h>#include<string.h>#include<stdlib.h>voidMain () {Charuser[ -],password[ -]; intLen1,len2; printf ("Please enter your user name: \ t"); scanf ("%s",&user); Len1=strlen (user); Len1+=3; printf ("Please enter your password: \ t"); scanf ("%s",&password); Len2=strlen (password); Len2-=2; if((len1-len2) = =0) {printf ("\ n \ nthe successful landing"); System ("Pause"); }    Else{printf ("\ n \ nthe password error \ n"); System ("Pause"); }}

The second method:

#include <stdio.h>#include<string.h>#include<stdlib.h>voidMain () {Charuser[ -],password[ -]; Charpass[ -]={0}; Charpacc[]="NULL"; Charpasc[]="SKHRBNC"; printf ("Please enter your user name: \ t"); scanf ("%s",&user); printf ("Please enter your password: \ t"); scanf ("%s",&password);    strcat (PASS,PACC);    strcat (PASS,PASC); if(strcmp (pass,password) = =0) {printf ("\ n \ nthe successful landing"); System ("Pause"); }    Else{printf ("\ n \ nthe password error \ n"); System ("Pause"); }}

The third method:

#include <stdio.h>#include<stdlib.h>#include<string.h>voidMain () {intI,n; Charuser[ +]; intpassword; printf ("User name:"); scanf ("%s", user); printf ("\ n Password:"); scanf ("%d",&password); if(strcmp (User,"Admin")==0) {n=2;  for(i=0;i<Ten; i++) {n*=2; }        if((password-n) = =0) {printf ("\ n \ nthe successful landing"); }        Elseprintf"\ n \ nthe user name or password error \ n"); }    Elseprintf"\ n \ nthe user name or password error \ n"); System ("Pause");}

The Fifth method:

#include <stdio.h>#include<string.h>intMainvoid){    Charuser[ -]; Charmima[ -]; inti; intJ; printf ("Please enter user name:"); scanf ("%s",&user); printf ("\ n Please enter your password:"); 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 ("you're more than Frog frog."); }        Elseprintf"you don't have frog frogs."); return 0;}

We can try to write it in other ways.

Several different algorithms for registration code comparison

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.