当前位置:网站首页>【带你学c带你飞】第3章 分支结构(练习3.1 简单的猜数游戏)
【带你学c带你飞】第3章 分支结构(练习3.1 简单的猜数游戏)
2022-07-22 09:48:00 【尽力漂亮】
R1-1
if-else语句的 无括号形式如下,其中的语句1、语句2只能是一条语句。
R1-6
单等号赋值,双等号判断
奇偶分家
给定N个正整数,请统计奇数和偶数各有多少个?
输入格式:
输入第一行给出一个正整N(≤1000);第2行给出N个非负整数,以空格分隔。
输出格式:
在一行中先后输出奇数的个数、偶数的个数。中间以1个空格分隔
#include<stdio.h>
int main(){
int n1,n2;
int ji=0,ou=0;
scanf("%d",&n1);
for(int i=0;i<n1;i++){
scanf("%d",&n2);
if(n2%2==0){
ou++;
}else{
ji++;
};
}
printf("%d %d",ji,ou);
return 0;
}
配合使用动态循环使用更加
边栏推荐
- idea快速上手指南
- LeetCode 每日一题 2022/1/10-2022/1/16
- How can one page nest another page in thymeleaf? About page nesting, the tag tells you what you should know
- garbage collection
- Jackson parsing JSON detailed tutorial
- LeetCode 每日一题 2022/1/3-2022/1/9
- Bit and: the result of a number & 1
- 2022版Centos8 yum镜像安装&阿里云安装Mysql 5.7教程与问题解决
- Flutter's first program Hello world!
- Fluent adjusts the drawing shape by dragging
猜你喜欢
工业路由器油田无线监控
Grafana panel - about conversion
grafana面板-修改可视化文本和背景颜色
Enumerate properties in objects
Flutter's first program Hello world!
Laravel solves [1045] access denied for user 'homestead' @ 'localhost' (usin g password: yes)
Mysql5.7 decompression configuration steps
用指针遍历数组
Rongyun ramble: no one can avoid "video conference"
Introduction to date object
随机推荐
MFC dialog program only runs a simple example of a single instance
Scope and lifecycle of beans
Leetcode daily question 2022/2/7-2022/2/13
DOM introduction and query
JS advanced - understanding of objects
Force deduction solution summary 498 diagonal traversal
Global scope and function scope
What is "real time"
关于红队方面的学习资料
garbage collection
Bit and: the result of a number & 1
Execute function now
Idea Quick Start Guide
LeetCode 每日一题 2022/3/21-2022/3/27
Bean 的作用域和生命周期
Leetcode daily question 2022/3/14-2022/3/20
Rongyun ramble: no one can avoid "video conference"
Flutter's first program Hello world!
How can one page nest another page in thymeleaf? About page nesting, the tag tells you what you should know
十年架构五年生活-05第一次出差