1 solutions
-
0
C :
#include<stdio.h> int main(){ int x,y; scanf("%d",&x); if(x<0) y=-1; else if(x==0) y=0; else y=1; printf("%d\n",y); return 0; }C++ :
#include <stdio.h> int main() { int x, y; scanf("%d", &x); if (x < 0) y = -1; else if (x == 0) y = 0; else if (x > 0) y = 1; printf("%d\n", y); return 0; }Pascal :
var n:longint; begin readln(n); if n>0 then writeln('1'); if n=0 then writeln('0'); if n<0 then writeln('-1'); end.Java :
import java.util.*; public class Main { public static void main(String args[]) { Scanner cin=new Scanner(System.in); int i=cin.nextInt(); if(i>0) System.out.println(1); else if(i==0) System.out.println(0); else System.out.println(-1); } }Python :
x = input() if x < 0: print -1 elif x == 0: print 0 else: print 1
- 1
Information
- ID
- 16654
- Time
- 1000ms
- Memory
- 32MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By