当前位置:网站首页>C语言 换个格式输出整数
C语言 换个格式输出整数
2022-06-30 01:25:00 【Martin の Blog】

算法设计思路
- 获取输入数字的百位、十位、个位
- 按照数字每位的大小进行存储相应的信息
- 打印信息的时候,需要注意:字符和数字分开打印,不然无法显示数字信息
代码
#include <stdio.h>
int main(){
int n, i;
scanf("%d", &n);
int b = (n - n % 100) / 100;
int g = n % 10;
int s = (n % 100 - g) / 10;
char a[27];
for(i=0; i<b; i++){
a[i] = 'B';
}
for(i=0; i<s; i++){
a[b + i] = 'S';
}
for(i=0; i<g; i++){
a[b + s + i] = i + 1;
}
for(i=0; i<b+s; i++){
printf("%c", a[i]);
}
for(i=b+s; i<b+s+g; i++){
printf("%d", a[i]);
}
return 0;
}
运行结果
边栏推荐
- Interview summary
- Cub school learning: manual query and ADC in-depth use
- post请求出现WebKitFormBoundaryk的解决办法
- 数字垃圾是什么?跟随世界第一位AI艺术家,探索元碳艺术
- Is the course of digging money reliable and safe to open an account?
- js内容混淆,返回内容加密
- Visual studio 2017 cannot open the include file: 'qopenglfunctions_3_3_core': no such file or directory
- Cookie加密12
- How to unify the use of package manager in a project?
- JS prototype and prototype chain (Lantern Festival meal)
猜你喜欢

Seata and the three platforms are working together in the summer of programming. Millions of bonuses are waiting for you

Tetris game based on STM32F103

Text classification using huggingface

Stimulus reports reporting tool, stimulus creates and builds reports
![[recommendation system] concise principle and code implementation of user based collaborative filtering](/img/3b/d46e37e7ae245cf2931d32d1ebbe4c.png)
[recommendation system] concise principle and code implementation of user based collaborative filtering

Online text digit recognition list summation tool

What is digital garbage? Follow the world's first AI artist to explore meta carbon Art

Seata 与三大平台携手编程之夏,百万奖金等你来拿

In depth analysis of a large number of clos on the server_ The root of wait

数字垃圾是什么?跟随世界第一位AI艺术家,探索元碳艺术
随机推荐
Equivalence class partition method for test case design method
The unity editor randomly generates objects. After changing the scene, the problem of object loss is solved
The first unlucky person watching eth 2.0
Difference between test plan and test plan
JS prototype and prototype chain (Lantern Festival meal)
ES6 one line code for array de duplication
Understand the module function of MES management system
I learned database at station B (V): DQL exercise
Cub school learning: manual query and ADC in-depth use
Ansible ad-hoc temporary command
js返回内容被unicode编码
Varnish 基础概览2
Error reporting in Luban H5 installation
cookie加密9
挖财的课程靠谱吗,让开户安全吗?
Text classification using huggingface
Quality management of functional modules of MES management system
What is digital garbage? Follow the world's first AI artist to explore meta carbon Art
HC32M0+ GPIO
Clean, talk, bring children, and get rid of the label of "artificial mental retardation" for the sweeper