|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
int main()
{
char a, b, c, g = 'W', h = 'R',j = 'C';//前三位字符密码
int d, e, f,D=1,E=9,F=9,q,w,r,G,H,J,K;//后三位整型密码
printf("please input password:\n");
scanf_s("%c,%c,%c,%d,%d,%d", &a, &b, &c, &d, &e, &f);
G = g == a;//如果g==a则G=1,否则为0,以下同理
H = h == b;
J = j == c;
q = D == d;
w = E == e;
r = F == f;
K = G + H + J + q + w + r;//如果输入正确则K=6
if (K==6)//如果K=6执行下面括号的语句
{
printf("please input long,wide:\n");
getchar();
scanf_s("%d,%d", &d, &e);
f = d + e;
printf("=%d\n", f);
}
else while (getchar());
system("pause");
return 0;
}
……scanf_s 搞的鬼,用 scanf 就没问题: #define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
int main()
{
char a, b, c, g = 'W', h = 'R', j = 'C';//前三位字符密码
int d, e, f, D = 1, E = 9, F = 9, q, w, r, G, H, J, K;//后三位整型密码
printf("please input password:\n");
scanf("%c,%c,%c,%d,%d,%d", &a, &b, &c, &d, &e, &f);
G = g == a;//如果g==a则G=1,否则为0,以下同理
H = h == b;
J = j == c;
q = D == d;
w = E == e;
r = F == f;
K = G + H + J + q + w + r;//如果输入正确则K=6
if (K == 6)//如果K=6执行下面括号的语句
{
printf("please input long,wide:\n");
getchar();
scanf("%d,%d", &d, &e);
f = d + e;
printf("=%d\n", f);
}
else while (getchar());
system("pause");
return 0;
}
|
|