知识点:
分支控制:分支控制
if(){}
else if(){}
else{}
#include <iostream> using namespace std; int main() { int t = 0; while (cin >> t) { if (t > 0) { cout << 1 << endl; } else if (t == 0) { cout << 0.5 << endl; } else { cout << 0 << endl; } } return 0; }
知识点:
分支控制:分支控制
if(){}
else if(){}
else{}
#include <iostream> using namespace std; int main() { int t = 0; while (cin >> t) { if (t > 0) { cout << 1 << endl; } else if (t == 0) { cout << 0.5 << endl; } else { cout << 0 << endl; } } return 0; }