If IsNumeric(Text1.Text) And Len(Text1.Text) = 6 And Text2.Text = "good" Then
MsgBox "输入正确,验证通过", vbOKCancel, "验证通过"
Else
If MsgBox("账号或密码错误", vbRetryCancel, "验证错误") = vbRetry Then
Text1.Text = ""
Text2.Text = ""
Text1.SetFocus
Else
End
End If
End If
End Sub
Private Sub Form_Load()
Text1.PasswordChar = "*"
End Sub
#include <string.h>struct e
{
char a[10]
char b[10]
}z
int main()
{ int t=0
char s[10],d[10]
FILE *p
void as()
if ((p=fopen("m.txt","r+"))==NULL)
{
p=fopen("m.txt","w+")
t=1
}
if(t==1)
{
printf("当前没有任何用户\n")
printf("请新建用户名: ")
scanf("%s",s)
printf("为用户设置密码: ")
scanf("%s",d)
strcpy(z.a,s)
strcpy(z.b,d)
fprintf(p,"%s %s",z.a,z.b)
fclose(p)
}
if(t==0)
{
printf("请输入用户名: ")
scanf("%s",s)
fscanf(p,"%s %s",z.a,z.b)
fclose(p)
if (!strcmp(z.a,s))
{
printf("请输入密码:")
scanf("%s",d)getchar()
if(!strcmp(z.b,d))
{ char i
printf("是否要修改密码?(输入y修改,n退出!)")
scanf("%c",&i)
if(i=='y')
{
printf("请输入修改密码:")
scanf("%s",z.b)
p=fopen("m.txt","w+")
fprintf(p,"%s %s",z.a,z.b)
fclose(p)
printf("修改成功!")
}
}
else printf("密码错误!")
}
else printf("用户名错误")
fclose(p)
}
}
#include <iostream>#include <string>
using namespace std
const int number=3
const string id[number]={"a","b","c"}
const string passwd[number]={"111","222","333"}
int main()
{
string m,n
int i
cin >>m
for(i=0 i < number i ++)
if(id[i] == m) break
if(i == number)
{
cout<< "用户不存在\n"
}
else
{
cin >>n
if(passwd[i] == n)
cout<<"欢迎!\n"
else cout<<"密码错误\n"
}
return 0
}
以上为基础功能.
扩展如下:
#include <iostream>#include <string>
using namespace std
const int number=3
const string id[number]={"a","b","c"}
const string passwd[number]={"111","222","333"}
int main()
{
string m,n
int i,times
for(times=0 times<3times++)
{
cin >>m
for(i=0 i < number i ++)
if(id[i] == m) break
if(i == number)
{
cout<< "请重新输入.\n"
}
else break
}
if(times == 3)
cout << "用户不存在\n"
else
{
for(times=0 times<3times++)
{
cin >>n
if(passwd[i] == n)
{
cout<<"欢迎!\n"
break
}
else cout<<"请重新输入.\n"
}
if(times==3) cout<<"密码错误\n"
}
return 0
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)