|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
兄弟们这是为什么啊,我只执行了第一个scanf后第二个还没输入就弹出来了
#include<stdio.h>
int main(void)
{
int a,s,d,f,g,h;
printf("Enter first date(mm/dd/yy):");
scanf("%1d/%1d/%1d",&a,&s,&d);
printf("Enter second date(mm/dd/yy):");
scanf("%1d/%1d/%1d",&f,&g,&h);
if(a>f){
printf("%d/%d/%d>%d/%d/%d",a,s,d,f,g,h);
}
if(a=f){
if(s>g)
printf("%d/%d/%d>%d/%d/%d",a,s,d,f,g,h);
else if(s<g){
printf("%d/%d/%d>%d/%d/%d",f,g,h,a,s,d); }
}
if(a<f){
printf("%d/%d/%d>%d/%d/%d",f,g,h,a,s,d);
}
if(a=f){
if(s=g)
if(d>h)
printf("%d/%d/%d>%d/%d/%d",a,s,d,f,g,h);
else if(d<h)
printf("%d/%d/%d>%d/%d/%d",f,g,h,a,s,d);
}
if(a=f)
if(s=g)
if(d=h)
printf("%d/%d/%d=%d/%d/%d",a,s,d,f,g,h);
return 0;
}
错误有三类:1、scanf内输入不应该控制位宽;2、判断相等应该是==,不是=,前者是比较运算符,后者是赋值运算符;3、你的输入是年/月/日还是月/日/年? #include<stdio.h>
int main(void)
{
int a, s, d, f, g, h;
printf("Enter first date(mm/dd/yy):");
scanf("%d/%d/%d", &s, &d, &a);
printf("Enter second date(mm/dd/yy):");
scanf("%d/%d/%d", &g, &h, &f);
if (a > f) {
printf("%d/%d/%d > %d/%d/%d", a, s, d, f, g, h);
}
if (a == f) {
if (s > g)
printf("%d/%d/%d > %d/%d/%d", a, s, d, f, g, h);
else if (s < g) {
printf("%d/%d/%d > %d/%d/%d", f, g, h, a, s, d);
}
}
if (a < f) {
printf("%d/%d/%d > %d/%d/%d", f, g, h, a, s, d);
}
if (a == f) {
if (s == g)
if (d > h)
printf("%d/%d/%d > %d/%d/%d", a, s, d, f, g, h);
else if (d < h)
printf("%d/%d/%d > %d/%d/%d", f, g, h, a, s, d);
}
if (a == f)
if (s == g)
if (d == h)
printf("%d/%d/%d = %d/%d/%d", a, s, d, f, g, h);
return 0;
}
|
-
-
|