当前位置:网站首页>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 3
- Machine learning notes: time series decomposition STL
- C language final without failing (Part 1)
- Pytroch Learning Notes 6: NN network layer convolution layer
- js逆向请求参数加密:
- Varnish 基础概览2
- Varnish foundation overview 1
- C语言 写出这个数
- MySQL monitoring
- What should be paid attention to in the design and production of the Urban Planning Museum
猜你喜欢
随机推荐
[Thesis Writing] English thesis writing guide
Varnish foundation overview 10
cookie加密8
【推荐系统】基于用户的协同过滤简明原理与代码实现
STC89C52 single chip microcomputer simple calculator design and code demonstration
Pytroch Learning Notes 6: NN network layer convolution layer
首届技术播客月开播在即
Seata and the three platforms are working together in the summer of programming. Millions of bonuses are waiting for you
What should be paid attention to in the design and production of the Urban Planning Museum
cookie加密9
Is the course of digging money reliable and safe to open an account?
js Array.from()的5个便捷应用
Machine learning notes: time series decomposition STL
Mysql 监控6
The first technology podcast month will be launched soon
What to remember about the penalty for deduction of points in Item 1
How does webapi relate to the database of MS SQL?
【图神经网络】图分类学习研究综述[2]:基于图神经网络的图分类
Varnish 基础概览6
Precautions for postoperative fundus hemorrhage / / must see every day
![[Thesis Writing] English thesis writing guide](/img/59/88d34814a88a2da19ed6a236825649.png)





![[MRCTF2020]Ezpop-1|php序列化](/img/65/9b7a3ae3552d8784b0c77a1130d762.png)


