当前位置:网站首页>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;
}
运行结果
边栏推荐
- cookie加密8
- Mysql 监控1
- [recommended] how to quickly locate a bug during testing
- Three text to speech artifacts, each of which is very practical
- 【机器学习Q&A】数据抽样和模型验证方法、超参数调优以及过拟合和欠拟合问题
- Seata and the three platforms are working together in the summer of programming. Millions of bonuses are waiting for you
- 传统微服务框架如何无缝过渡到服务网格 ASM
- “乘风破浪”的芒果超媒,能上岸吗?
- js Array.from()的5个便捷应用
- How to deal with occasional bugs?
猜你喜欢

81. search rotation sort array II

Tetris game based on STM32F103

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

Wechat applet - requestsubscribemessage:fail can only be invoked by user tap gesture

The listing of Symantec electronic sprint technology innovation board: it plans to raise 623million yuan, with a total of 64 patent applications

ES6 one line code for array de duplication

How to refuse the useless final review? Ape tutoring: it is important to find a suitable review method

Stimulus reports reporting tool, stimulus creates and builds reports

Pytroch Learning Notes 6: NN network layer convolution layer

I learned database at station B (V): DQL exercise
随机推荐
[Thesis Writing] English thesis writing guide
Cookie加密12
[three.js] Web3D first experience
Mechanical --nx2007 (UG) -- gap analysis (interference inspection)
Solving plane stress problem with MATLAB
c语言选择,循环概述
挖财的课程靠谱吗,让开户安全吗?
RubyMine开发工具,重构和意图操作
Statsmodels notes STL
【论文写作】英文论文写作指南
[535. encryption and decryption of tinyurl]
【535. TinyURL 的加密与解密】
Quick pow: how to quickly find power
In depth analysis of a large number of clos on the server_ The root of wait
GeoTools WKT坐标系转换
[mrctf2020]ezpop-1 | PHP serialization
首届技术播客月开播在即
阅读,是最廉价的高贵
Seata 与三大平台携手编程之夏,百万奖金等你来拿
Pytroch Learning Notes 6: NN network layer convolution layer