2 solutions

  • 0
    @ 2024-7-18 14:59:01
    #include<bits/stdc++.h>
    using namespace std;
    int main(){
    	string s;
    	cin>>s;
    	if(s=="0"){
    		cout<<0;
    		return 0;
    	}
    	int n=s.size();
    	string s1;
    	int cnt=0;
    	if(s[0]=='-') s1+='-';
    	for(int j=n-1;j>=0;j--){
    		if(s[j]=='-') continue;
    		if(cnt==0 && s[j]=='0') continue;
    		else{
    			s1+=s[j];
    			cnt++;
    		}
    	}
    	cout<<s1;
        return 0;
    }
    
    • 0
      @ 2024-6-11 11:51:08

      模拟题(100pts)

      • 翻转数基础模板
      #include<bits/stdc++.h>
      using namespace std;
      
      int main()
      {
        	int n;
        	cin>>n;
      	int res=0;
        	while(n) //翻转数基础模板 
        	{
        		int ge=n%10;
        		res=res*10+ge;
      		n/=10;	
      	}
      	cout<<res;
          return 0;
      }
      
      • 1

      Information

      ID
      433
      Time
      1000ms
      Memory
      128MiB
      Difficulty
      10
      Tags
      # Submissions
      4
      Accepted
      3
      Uploaded By