当前位置:网站首页>C language output integer in another format
C language output integer in another format
2022-06-30 01:31:00 【Martin の Blog】

Algorithm design ideas
- Get the hundred digits of the input number 、 ten 、 bits
- Store the corresponding information according to the size of each number
- When printing information , We need to pay attention to : Characters and numbers are printed separately , Otherwise, digital information cannot be displayed
Code
#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;
}
Running results 
边栏推荐
- MySQL monitoring
- Application of pointer in STC89C52 single chip microcomputer and demonstration of practical cases
- What is digital garbage? Follow the world's first AI artist to explore meta carbon Art
- JS anti shake and throttling
- C语言 成绩排名
- [MRCTF2020]Ezpop-1|php序列化
- Sentinel source code analysis Chapter 9 - core process - lookprocesschain finding resource processing chain
- js返回内容被unicode编码
- Machine learning notes: time series decomposition STL
- STC89C52 single chip microcomputer simple calculator design and code demonstration
猜你喜欢

Understand the module function of MES management system

Mechanical --nx2007 (UG) -- gap analysis (interference inspection)

C语言 我要通过

cookie加密9

Machinery -- nx2007 (UG) finite element analysis tutorial 1 -- simple object

魔百盒CM201-2-CH-Hi3798MV300-300H-EMMC和NAND_红外蓝牙语音_通刷固件包

【机器学习Q&A】余弦相似度、余弦距离、欧式距离以及机器学习中距离的含义

Resizekit2.net size and resolution independent
![[mrctf2020]ezpop-1 | PHP serialization](/img/65/9b7a3ae3552d8784b0c77a1130d762.png)
[mrctf2020]ezpop-1 | PHP serialization

Design and implementation of spark offline development framework
随机推荐
Mysql 监控5
Kubernetes 核心对象概览详解
GeoTools WKT坐标系转换
How does webapi relate to the database of MS SQL?
Cookie encryption 9
Sentinel source code analysis Part 7 - sentinel adapter module - Summary
ES6 synchronous asynchronous execution and block level scope
传统微服务框架如何无缝过渡到服务网格 ASM
Embedded test template
Cookie encryption 11
cookie加密11
OpenCV和Image之间的转换(亲测有效)
How to seamlessly transition from traditional microservice framework to service grid ASM
[535. encryption and decryption of tinyurl]
JS reverse request parameter encryption:
Mysql 监控2
Embedded exit (review and release)
The first technology podcast month will begin soon
Varnish 基础概览2
js内容混淆,返回内容加密