#include<bits/stdc++.h> using namespace std; int main(){ string s;//定义字符串s cin >> s; if (s == "0"){//特判s是否为0 cout << 0; return 0;//别忘记提前结束程序 } if (s[0] != '-'){//判断s的第一个元素是不是"-" cout << '-'; cout << s; }else{ cout << s; } return 0;//完结,撒花! }
#include <bits/stdc++.h> using namespace std; int main(){ int a; cin >> a; if(a > 0) //只有大于0的数需要变换后输出 { a = a - a - a; } cout << a; return 0; }
注册一个 睿爸信奥 通用账户,您就可以在我们提供的所有在线评测服务上提交代码、参与讨论。
使用您的 睿爸信奥 通用账户