1 solutions

  • 0
    @ 2025-3-3 16:33:58

    C :

    #include<stdio.h>
    int main(){
    	int x,y;
    	scanf("%d",&x);
    	if(x>0){
    		y=x+1;
    	}else if(x==0){
    		y=0;
    	}else{
    		y=x-1;
    	}
    	printf("%d",y);	
    	return 0;
    }
    

    C++ :

    #include<iostream>
    #include<iomanip>
    using namespace std;
    int main(){
    	int x,y;
    	cin>>x;
    	if(x<0){
    		y=x-1;
    	}else if(x==0){
    		y=0;
    	}else{
    		y=x+1;
    	}
    	cout<<y<<endl;
    	
    }
    	
    
    

    Python :

    x=int(input())
    if x>0:
        y=x+1
    elif x==0:
        y=0
    elif x<0:
        y=x-1
    print(y)
    
    • 1

    Information

    ID
    10820
    Time
    1000ms
    Memory
    16MiB
    Difficulty
    (None)
    Tags
    # Submissions
    0
    Accepted
    0
    Uploaded By