当前位置:网站首页>NOI OJ 1.3 13:反向输出一个三位数 C语言
NOI OJ 1.3 13:反向输出一个三位数 C语言
2022-06-23 10:12:00 【chd44】
描述
将一个三位数反向输出。
输入
一个三位数n。
输出
反向输出n。
这种题难度不大,但思维要活络,这里提供两个思路。
方法1:先求出百位的数字,再去掉个位,把十位数字求出来,最后用原数减去百位和十位,得到个位数,再一个个排序(比较笨的方法)。
#include<stdio.h>
int main(){
int a;
scanf("%d",&a);
int b=a/100;
int c=a/10-b*10;
int d=a-c*10-b*100;
printf("%d%d%d",d,c,b);
return 0;
}方法2:用求余的方式求出个位,十位通过整除10后在求余,百位直接整除100就行(稍微聪明点的办法)
#include<stdio.h>
int main(){
int a,b,c,d;
scanf("%d",&a);
b=a%10;
c=(a/10)%10;
d=a/100;
printf("%d%d%d",b,c,d);
return 0;
}边栏推荐
- MySQL-01.工作中数据库优化和explain字段知识的总结
- 高性能算力中心 — NVMe/NVMe-oF — NVMe-oF Overview
- 2021-05-11instanceof和类型转换
- 实现领域驱动设计 - 使用ABP框架 - 通用准则
- High performance computing center RDMA implementation technology
- NFTs、Web3和元宇宙对数字营销意味着什么?
- Shengshihaotong enables high-quality development with industrial Digitalization
- 2021-05-07 package inheritance super this
- AI芯片技术-2022年
- Simple understanding of quick sort
猜你喜欢

一个优秀速开发框架是什么样的?

R和RStudio下载安装详细步骤

JVM简单入门-01

个人博客系统毕业设计开题报告

Confessing with Snake games (with source code)

Build the information and innovation industry ecology, and make mobile cloud based on the whole stack of independent innovation

基于STM32设计的宠物投喂器

File IO (1)

Cloud native database Amazon RDS

Comic | code review is driving me crazy!
随机推荐
Unity技术手册 - 生命周期LifetimebyEmitterSpeed-周期内颜色ColorOverLifetime-速度颜色ColorBySpeed
After the uncommitted transactions in the redo log buffer of MySQL InnoDB are persisted to the redo log, what happens if the transaction rollback occurs? How does the redo log handle this transaction
Comic | code review is driving me crazy!
NFTs、Web3和元宇宙对数字营销意味着什么?
MySQL optimistic lock and pessimistic lock
IPv6 的速度比 IPv4 更快?
Three implementation methods of distributed lock
Golang 快速上手 (3)
Year end answer sheet! Tencent cloud intelligent comprehensive strength ranks first in China!
2022高考季征文获奖名单公布
大作业合集
快速排序的简单理解
Implementing Domain Driven Design - using ABP framework - General guidelines
How to pass values to onclick events in thymeleaf
数值计算方法
JS教程之 什么是 JSX?为什么我们需要它?
Pycharm installation tutorial, super detailed
2021-05-12内部类
Build a QQ robot to wake up your girlfriend
Centre de calcul haute performance - nvme / nvme - of - nvme - of overview