当前位置:网站首页>电子协会 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博客
边栏推荐
- Based on Simulink and FlightGear, the dynamic control of multi rotor UAV in equilibrium is modeled and simulated
- Exclusive delivery of secret script move disassembly (the first time)
- [IVX junior engineer training course 10 papers to get certificates] 03 events and guessing numbers games
- Global and Chinese market of safety detection systems 2022-2028: Research Report on technology, participants, trends, market size and share
- SAP ui5 beginner tutorial 20 - explanation of expression binding usage of SAP ui5
- Basic concepts of machine learning
- 969 interlaced string
- GL Studio 5 安装与体验
- 遷移雲計算工作負載的四個基本策略
- Just using the way and method of consuming the Internet to land and practice the industrial Internet will not bring long-term development
猜你喜欢

Android: how can golden nine and silver ten squeeze into the first-line big factories from small and medium-sized enterprises? The depth of interview questions in large factories

ES6 new method of string

Android high frequency network interview topic must know and be able to compare Android development environment

Docker installing Oracle_ 11g

微信小程序中使用tabBar

浅浅了解Servlet

技术大佬准备就绪,话题C位由你决定

教你白嫖Amazon rds一年并搭建MySQL云数据库(只需10分钟,真香)

6-3 vulnerability exploitation SSH environment construction

Datawhale 社区黑板报(第1期)
随机推荐
Réseau neuronal convolutif (y compris le Code et l'illustration correspondante)
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
SQL injection for Web Security (2)
Using tabbar in wechat applet
error: . repo/manifests/: contains uncommitted changes
Single chip microcomputer -- hlk-w801 transplant NES simulator (III)
Load and domcontentloaded in JS
Learning note 3 -- Key Technologies of high-precision map (Part 1)
10 minutes to get started quickly composition API (setup syntax sugar writing method)
Edge computing accelerates live video scenes: clearer, smoother, and more real-time
Introduction to ffmpeg Lib
How does schedulerx help users solve the problem of distributed task scheduling?
Leetcode 45 Jumping game II (2022.02.14)
Luogu p1775 stone merger (weakened version)
Cat Party (Easy Edition)
LeetCode、3无重复最长子序列
What are the differences between software testers with a monthly salary of 7K and 25K? Leaders look up to you when they master it
[IVX junior engineer training course 10 papers] 02 numerical binding and adaptive website production
【疾病检测】基于BP神经网络实现肺癌检测系统含GUI界面
学习笔记3--高精度地图关键技术(上)