bshy.net
当前位置:首页>>关于从键盘输入一个非负整数n,若为奇数,输出"Odd";若为...的资料>>

从键盘输入一个非负整数n,若为奇数,输出"Odd";若为...

#include int main() {int n; scanf("%d",&n); if(n%2)printf("Odd\n"); else printf("Even\n"); return 0; }

C语言的如下 #include main() { int x; printf("输入一个整数:"); scanf("%d",&x); if(x==0) printf("zero\n"); else if(x%2==0) printf("even\n"); else printf("odd\n"); } C++语言的如下 #include void main() { int x; coutx; if(x==0) cout

#include using namespace std; void main() { int n; cout > n; if(!n) cout

#include "stdio.h" main() { int x; printf("请输入一个整数"); scanf("%d",&x); if(x%2 == 0) printf("%d是偶数\n",x); else printf("%d是奇数\n",x); }

1.对2取余为零为偶数,非零即为奇数 #include int main(){ int num; for (int i = 0; i < 2; i++) { printf("intput a number:"); scanf("%d", &num); if (num % 2 == 0) printf("It's Even.\n"); else printf("It's Odd.\n"); } return 0;}

#include main() { int num,yushu; printf("Please enter the number\n"); scanf("%d",&num); yushu=num%2; if (yushu==0) printf("Is Even\n"); else printf("Is Odd\n"); }

#include void main(){ int test; printf("please key in an integer to be tested:\n"); scanf("%d",&test); printf((test % 2 == 0)?"Is even":"Is odd"); }

main() { int i,n,sum=0; scanf("%d",&n); n*=2; for(i=1;i

#include int odd(int n) { if(n%2==0) return 0; else return 1; } void main() { int n; printf("input n:"); scanf("%d",&n); if(odd(n)) printf("no\n"); else printf("yes\n"); }

DATA SEGMENT MSG1 DB 'PARTY','$' MSG2 DB 'ODD','$' DATA ENDS CODE SEGMENT ASSUME CS:CODE START: MOV AX,DATA MOV DS,AX MOV AH,00H INT 16H ;接受一个数 SUB AL,30H MOV BL,2 DIV BL CMP AH,0;除2看余数为零否 JNZ OP MOV DX,OFFSET MSG1;...

网站首页 | 网站地图
All rights reserved Powered by www.bshy.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com