今天看到一个有趣的if语句,拿出来和大家分享一下,也许以后会多一种条件判断的方式
/*题目:
int main()
{
if()
{
printf("Hello ");
}
else
{
printf("World !!!");
}
return 0;
}
在if里面请写入语句 使得打印出 hello world。
*/
#include <stdio.h>
#include <stdlib.h>
int main()
{
if((puts("hello world"), exit(0), 123))
{
printf("Hello ");
}
else
{
printf("World !!!");
}
return 0;
}
/*
puts("hello world") 输出字符串并换行
exit(0) 正常终止程序
最后一个逗号表达式返回123值给if,即if(123)
*/