Python
while True: num = int(input()) if (num % 2) == 0: print('偶数') else: print('奇数')
C 语言
#include <stdio.h> int main(){ while (1){ int num; scanf("%d", &num); if ((num % 2) == 0){ printf("偶数"); }else{ printf("奇数"); } } }
JAVA(ChatGPT翻译)
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); while (true) { int num = scanner.nextInt(); if (num % 2 == 0) { System.out.println("偶数"); } else { System.out.println("奇数"); } } } }
PinkShell
$ mode compile; defined function auto_int main() do while do auto_int num -> input(); if (num % 2) == 0 then output.echo('偶数'); else output.echo('奇数'); end end end