关于else后的输出语句!
#include "stdio.h"main()
{
int x,y,z;
x=1;
y=2;
z=3;
if(x>y)
if(x>z) printf("%d",x);
else
printf("%d",y);
printf("%d\n",z);
getch();
}
为什么结果是3,高手些,说一下,尽量详细,谢谢~````
#include "stdio.h" int main() { int x,y,z; x=1; y=2; z=3; if(x>y)//1>2不成立,直接输出z { if(x>z) printf("%d",x); else printf("%d",y); } printf("%d\n",z);// getch(); }
#include<stdio.h> int main(int argc, char* argv[]) { int x=1,y=2,z=3; printf("%d\n",x>y? (x>z?x:z) : (y>z?y:z) ); return 0; }