计算单位阶跃函数
#include<bits/stdc++.h>
using namespace std;
int main(){
int t;
while(cin >> t){
if(t > 0){
cout << 1 << endl;
} else if(t == 0){
cout << 0.5 << endl;
} else {
cout << 0 << endl;
}
}
return 0;
}
#include<bits/stdc++.h>
using namespace std;
int main(){
int t;
while(cin >> t){
if(t > 0){
cout << 1 << endl;
} else if(t == 0){
cout << 0.5 << endl;
} else {
cout << 0 << endl;
}
}
return 0;
}
相关推荐