当前位置:网站首页>电子协会 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博客
边栏推荐
- Brief introduction to the development of mobile network
- How does schedulerx help users solve the problem of distributed task scheduling?
- [Chongqing Guangdong education] Tianshui Normal University universe exploration reference
- Two TVs
- 技术大佬准备就绪,话题C位由你决定
- [IVX junior engineer training course 10 papers to get certificates] 01 learn about IVX and complete the New Year greeting card
- Mathematics - feelings -20220215
- 6-3漏洞利用-SSH环境搭建
- Architecture evolution from MVC to DDD
- Global and Chinese markets for the application of artificial intelligence in security, public security and national security 2022-2028: Research Report on technology, participants, trends, market size
猜你喜欢
教你白嫖Amazon rds一年并搭建MySQL云数据库(只需10分钟,真香)
学习笔记25--多传感器前融合技术
Develop a simple login logic based on SSM
基于SSM实现微博系统
[Floyd] post disaster reconstruction
Learn about servlets
969 interlaced string
Datawhale 社区黑板报(第1期)
Infiltration records of CFS shooting range in the fourth phase of the western regions' Dadu Mansion
matlab 实现语音信号重采样和归一化,并播放比对效果
随机推荐
Liteos learning - first knowledge of development environment
SQL injection for Web Security (2)
[image enhancement] vascular image enhancement based on frangi filter with matlab code
Hcip day 14 (MPLS protocol)
Principle of finding combinatorial number and template code
企业应该选择无服务器计算吗?
Leetcode, 3 repeatless longest subsequence
Using tabbar in wechat applet
[dynamic planning] interval dp:p3205 Chorus
[IVX junior engineer training course 10 papers] 04 canvas and a group photo of IVX and me
学习笔记25--多传感器前融合技术
We should make clear the branch prediction
[IVX junior engineer training course 10 papers to get certificates] 0708 news page production
Learn C language from scratch day 025 (maze)
Datawhale community blackboard newspaper (issue 1)
What are the affordable Bluetooth headsets? Student party parity Bluetooth headset recommendation
Fastadmin controls the length of fields in the table
Basic number theory -- Gauss elimination
Global and Chinese markets for supply chain strategy and operation consulting 2022-2028: Research Report on technology, participants, trends, market size and share
首场“移动云杯”空宣会,期待与开发者一起共创算网新世界!