当前位置:网站首页>电子协会 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博客
边栏推荐
- The author is more willing to regard industrial Internet as a concept much richer than consumer Internet
- 学习笔记24--多传感器后融合技术
- 迁移云计算工作负载的四个基本策略
- [Floyd] post disaster reconstruction
- Docker installing Oracle_ 11g
- It's already 30. Can you learn programming from scratch?
- Another programmer "deleted the library and ran away", deleted the code of the retail platform, and was sentenced to 10 months
- Mathematics - feelings -20220215
- Ubuntu20.04 PostgreSQL 14 installation configuration record
- 6-3漏洞利用-SSH环境搭建
猜你喜欢
Sql--- related transactions
卷積神經網絡(包含代碼與相應圖解)
[Floyd] post disaster reconstruction
[Obsidian] wechat is sent to Obsidian using remotely save S3 compatibility
ES6 new method of string
Data visualization in medical and healthcare applications
机器学习基本概念
微信小程序中使用tabBar
SAP ui5 beginner tutorial 20 - explanation of expression binding usage of SAP ui5
GL Studio 5 installation and experience
随机推荐
Single chip microcomputer -- hlk-w801 transplant NES simulator (III)
学习笔记24--多传感器后融合技术
Error creating bean with name ‘stringRedisTemplate‘ defined in class path re
We should make clear the branch prediction
LeetCode、3无重复最长子序列
How does schedulerx help users solve the problem of distributed task scheduling?
Introduction to ffmpeg Lib
[IVX junior engineer training course 10 papers] 02 numerical binding and adaptive website production
What is commercial endowment insurance? Is commercial endowment insurance safe?
Variables and constants of go language foundation
Mathematics - feelings -20220215
6-3 vulnerability exploitation SSH environment construction
Recommend an online interface mock tool usemock
企业应该选择无服务器计算吗?
What are the affordable Bluetooth headsets? Student party parity Bluetooth headset recommendation
Learn C language from scratch day 025 (maze)
How can I batch produce the same title for the video?
[IVX junior engineer training course 10 papers to get certificates] 09 chat room production
Load and domcontentloaded in JS
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