2 条题解

  • 3
    @ 2025-1-15 17:16:19
    #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;//完结,撒花!
    }
    
    • 0
      @ 2025-3-16 19:58:10
      #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;
      }
      
      • 1

      信息

      ID
      7
      时间
      1000ms
      内存
      128MiB
      难度
      6
      标签
      (无)
      递交数
      281
      已通过
      77
      上传者