標題:
[練習] if...else ~~(驚嘆號,true,false)
[打印本頁]
作者:
陳品肇
時間:
2019-3-30 10:05
標題:
[練習] if...else ~~(驚嘆號,true,false)
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
// 5>4 正確的 true 跑上面的結果 3<4 錯誤的 false 跑下面的結果
if(!true) // 加了一個驚嘆號 變成反向結果
{
cout<<"true"<<endl;
}else
{
cout<<"false"<<endl;
}
cout<<"============================="<<endl;
if(120 != 120 ) // != 不等於 120 != 120 ==等於 120 ==120
{
cout<<"血壓正常~"<<endl;
}else
{
cout<<"血壓異常!!!"<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
謝蓮金
時間:
2019-3-30 11:47
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int a,b,c;
cin>>a;
cin>>b;
cin>>c;
if((a>100&&b<5)||c>120)
{
cout<<"ture"<<endl;
}else
{
cout<<"false"<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
邱楷宸
時間:
2019-3-30 11:48
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
if(!true)
{
cout<<"true"<<endl;
}else
{
cout<<"false"<<endl;
}
cout<<"============================="<<endl;
if(120 != 120 )
{
cout<<"血壓正常~"<<endl;
}else
{
cout<<"血壓異常!!!"<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
李易展
時間:
2019-3-30 11:49
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
//re:
if(!!false)
{
cout<<"true"<<endl;
}else
{
cout<<"false"<<endl;
}
if(120 == 120 )
{
cout<<"正常~~~~~~~~~"<<endl;
}else
{
cout<<"*不正常呀!!"<<endl;
}
cout<<""<<endl;
if(120 != 120 )
{
cout<<"good"<<endl;
}else
{
cout<<"bad!!!"<<endl;
}
//goto re;
system("pause");
return 0;
}
複製代碼
作者:
洪子涵
時間:
2019-3-30 11:49
#include<cstdlib>
#include<iostream>
using namespace std;
int main()
{
if(60>20&&30>90||60>40)
{
cout<<"正確"<<endl;
}
else
{
cout<<"不正確 "<<endl;
}
if(true&&!(30>90))
{
cout<<"正確"<<endl;
}
else
{
cout<<"不正確 "<<endl;
}
if(true&&(30>90))
{
cout<<"正確"<<endl;
}
else
{
cout<<"不正確 "<<endl;
}
if(0)
{
cout<<"正確"<<endl;
}
else
{
cout<<"不正確 "<<endl;
}
if(1&&true)
{
cout<<"正確"<<endl;
}
else
{
cout<<"不正確 "<<endl;
}
if(1&&900||6)
{
cout<<"正確"<<endl;
}
else
{
cout<<"不正確 "<<endl;
}
if(90<0&&!0)
{
cout<<"正確"<<endl;
}
else
{
cout<<"不正確 "<<endl;
}
if(!false||5<6)
{
cout<<"正確"<<endl;
}
else
{
cout<<"不正確 "<<endl;
}
if(30==9)
{
cout<<"正確"<<endl;
}
else
{
cout<<"不正確 "<<endl;
}
system("pause");
return 0 ;
}
複製代碼
作者:
洪藜芸
時間:
2019-3-30 11:50
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int x,y,a,b;
cout<<"請輸入收縮壓:";
cin>>x;
cout<<"請輸入舒張壓:";
cin>>y;
if(x <120 && y <80 )
{
cout<<"正常"<<endl;
}
else
{
cout<<"有問題,建議詢問醫生"<<endl;
}
if(true)
{
cout<<"......?...好像不正常?"<<endl;
}
else
{
cout<<"你很健康。"<<endl;
}
if(!true)
{
cout<<"等等!你病了!"<<endl;
}
else
{
cout<<"不對,你沒什麼問題"<<endl;
}if(false)
{
cout<<"不對,你沒什麼問題"<<endl;
}
else
{
cout<<"你病了。"<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
黃傳耀
時間:
2019-3-30 11:51
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int a,b,c;
cout<<"Please input a number:";
cin>>a;
cout<<"Please input another number:";
cin>>b;
cout<<"Please input another number again:";
cin>>c;
if(!(a>60) && (b>60 || c>80))
{
cout<<"Great"<<endl;
}else
{
cout<<"not great"<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
王建葦
時間:
2019-4-3 21:02
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
if(!true)
{
cout<<"良好"<<endl;
}
else
{
cout<<"不良好"<<endl;
}
cout<<"========================"<<endl;
if(120!=120)
{
cout<<"血壓正常~"<<endl;
}
else
{
cout<<"血壓異常~"<<endl;
}
system("pause");
return 0;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2