2 条题解

  • 0
    @ 2023-10-28 17:00:06

    这题似乎需要字符串,double似乎不行。

    #include <bits/stdc++.h>
    using namespace std;
    int main()
    {
        string n;
        cin>>n;
        if(n[0]=='-')cout<<n;
        else cout<<'-'<<n;
        return 0;
    }
    
    • 0
      @ 2023-8-21 11:51:10
      #include <iostream>
      #include <string>
      using namespace std;
      int main()
      {
      	string n;
      	cin >> n;
      	//如果为负数照常输出 
      	if(n[0] == '-')
      	{
      		cout << n << endl;
      	}
      	//如果为0照常输出 
      	else if(n == "0") cout << n << endl;
      	//如果为不是负数加上负号照常输出 
      	else
      	{
      		cout << "-" << n << endl;
      	}
      	return 0;
      }
      
      • 1

      信息

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