当前位置:网站首页>电子协会 C语言 1级 33 、奇偶数判断
电子协会 C语言 1级 33 、奇偶数判断
2022-07-02 01:29:00 【dllglvzhenfeng】
电子协会 C语言 1级 33 、奇偶数判断
C++代码:方法一
/*
电子协会 C语言 1级 33 、奇偶数判断 方法一
http://noi.openjudge.cn/ch0104/03/
给定一个整数,判断该数是奇数还是偶数。
输入
输入仅一行,一个大于零的正整数 n。
输出
输出仅一行,如果 n 是奇数,输出 odd;如果 n 是偶数,输出 even。
样例输入
5
样例输出
odd
*/
#include<iostream>
using namespace std;
int main()
{
int n;
cin>>n;
( n%2 == 0 ) ? cout<<"even" : cout<<"odd" ;
//cout<<int(3.5);
return 0;
}C++代码:方法二
/*
电子协会 C语言 1级 33 、奇偶数判断 方法二
http://noi.openjudge.cn/ch0104/03/
给定一个整数,判断该数是奇数还是偶数。
输入
输入仅一行,一个大于零的正整数 n。
输出
输出仅一行,如果 n 是奇数,输出 odd;如果 n 是偶数,输出 even。
样例输入
5
样例输出
odd
*/
#include<iostream>
using namespace std;
int main(void)
{
int x;
cin>>x;
if( x%2==1)
{
cout<<"odd"<<endl;
}
else
{
cout<<"even"<<endl;
}
return 0;
}C代码:
#include <stdio.h>
#include <stdlib.h>
int main()
{
int a;
scanf("%d",&a);
if(a%2==0) printf("even");
else printf("odd");
//system("pause");
return 0;
}python3代码:
n = int(input())
if n % 2:
print("odd")
else:
print("even")NOIP初赛 CSP-J1 CSP-S1 第1轮 初赛 信奥中的数学知识(一)
NOIP初赛 CSP-J1 CSP-S1 第1轮 初赛 信奥中的数学知识(一)_dllglvzhenfeng的博客-CSDN博客
NOIP初赛 CSP-J1 CSP-S1 第1轮 初赛 信奥中的数学知识(二)
NOIP初赛 CSP-J1 CSP-S1 第1轮 初赛 信奥中的数学知识(二)_dllglvzhenfeng的博客-CSDN博客
NOIP初赛 CSP-J1 CSP-S1 第1轮 初赛 信奥中的数学知识(三)
NOIP初赛 CSP-J1 CSP-S1 第1轮 初赛 信奥中的数学知识(三)_dllglvzhenfeng的博客-CSDN博客
2022年 CSP-J1 CSP-S1 初赛 如何进行复习 如何做题
2022年 CSP-J1 CSP-S1 初赛 如何进行复习 如何做题_dllglvzhenfeng的博客-CSDN博客
2021 CSP-J1 CSP-S1 第1轮 初赛 最后一周的计划(2021.09.15)
2021 CSP-J1 CSP-S1 第1轮 初赛 最后一周的计划(2021.09.15)_dllglvzhenfeng的博客-CSDN博客
2021CSP-J1初赛答案与讲评
2021CSP-J1初赛答案与讲评_以太以北的博客-CSDN博客
2022年暑期及9月份CSP-J1 CSP-S1初赛 培训计划及学习要点
2022年暑期及9月份CSP-J1 CSP-S1初赛 培训计划及学习要点_dllglvzhenfeng的博客-CSDN博客
NOIP普及组2006-2018初赛 2019 CSP-J1 2020 CSP-J1 完善程序题
NOIP普及组2006-2018初赛 2019 CSP-J1 2020 CSP-J1 完善程序题_dllglvzhenfeng的博客-CSDN博客
NOIP2006-2018 提高组 初赛试题完善程序题 CSP-S 2019 2020 初赛试题完善程序题
NOIP2006-2018 提高组 初赛试题完善程序题 CSP-S 2019 2020 初赛试题完善程序题_dllglvzhenfeng的博客-CSDN博客
边栏推荐
- [IVX junior engineer training course 10 papers] 05 canvas and aircraft war game production
- Brief introduction to the development of mobile network
- 卷積神經網絡(包含代碼與相應圖解)
- Two TVs
- Private project practice sharing [Yugong series] February 2022 U3D full stack class 009 unity object creation
- Error creating bean with name ‘stringRedisTemplate‘ defined in class path re
- Global and Chinese market of collaborative applications 2022-2028: Research Report on technology, participants, trends, market size and share
- A problem about function template specialization
- Recommend an online interface mock tool usemock
- ACM教程 - 快速排序(常规 + 尾递归 + 随机基准数)
猜你喜欢

About asp Net core uses a small detail of datetime date type parameter

The first "mobile cloud Cup" empty publicity meeting, looking forward to working with developers to create a new world of computing!
![[IVX junior engineer training course 10 papers] 02 numerical binding and adaptive website production](/img/b7/aecb815ca9545981563a1e16cfa19e.jpg)
[IVX junior engineer training course 10 papers] 02 numerical binding and adaptive website production

The pain of Xiao Sha

Principle of finding combinatorial number and template code

This is the report that leaders like! Learn dynamic visual charts, promotion and salary increase are indispensable

【图像增强】基于Frangi滤波器实现血管图像增强附matlab代码

Edge computing accelerates live video scenes: clearer, smoother, and more real-time
![[Maya] the error of importing Maya into Metahuman](/img/46/46bd1c2d507c9e48ef8c066c54231d.jpg)
[Maya] the error of importing Maya into Metahuman

学习笔记3--高精度地图关键技术(上)
随机推荐
How to compress video size while adding watermark with one click?
ECS project deployment
GL Studio 5 installation and experience
Exclusive delivery of secret script move disassembly (the first time)
Basic concepts of machine learning
Recommend an online interface mock tool usemock
学习笔记24--多传感器后融合技术
Introduction to ffmpeg Lib
6-3漏洞利用-SSH环境搭建
The technology boss is ready, and the topic of position C is up to you
[Maya] the error of importing Maya into Metahuman
MySQL winter vacation self-study 2022 12 (4)
Appium inspector can directly locate the WebView page. Does anyone know the principle
Global and Chinese market of avionics systems 2022-2028: Research Report on technology, participants, trends, market size and share
遷移雲計算工作負載的四個基本策略
技术大佬准备就绪,话题C位由你决定
I'll teach you to visit Amazon RDS for a year and build a MySQL cloud database (only 10 minutes, really fragrant)
It's already 30. Can you learn programming from scratch?
[IVX junior engineer training course 10 papers] 04 canvas and a group photo of IVX and me
[IVX junior engineer training course 10 papers to get certificates] 01 learn about IVX and complete the New Year greeting card