当前位置:网站首页>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 
边栏推荐
- 3-6sql injection website instance step 5: break through the background to obtain web administrator permissions
- C语言 素数对猜想
- 挖财的课程靠谱吗,让开户安全吗?
- C language final without failing (Part 1)
- c语言期末不挂科(上)
- 【535. TinyURL 的加密与解密】
- How does webapi relate to the database of MS SQL?
- MySQL monitoring 3
- Stringredistemplate disconnects and the value disappears
- Seata and the three platforms are working together in the summer of programming. Millions of bonuses are waiting for you
猜你喜欢

C语言 写出这个数

首届技术播客月开播在即

Understand the module function of MES management system
![[mrctf2020]ezpop-1 | PHP serialization](/img/65/9b7a3ae3552d8784b0c77a1130d762.png)
[mrctf2020]ezpop-1 | PHP serialization

【论文写作】英文论文写作指南

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

C语言 一元多项式求导

The 8th "Internet +" competition - cloud native track invites you to challenge

Application features and functions of painting Aquarium

C语言 害死人不偿命的(3n+1)猜想
随机推荐
Questions about database: database attachment
Varnish foundation overview 3
Varnish 基础概览4
Storage engine analysis
[Thesis Writing] English thesis writing guide
Varnish 基础概览3
Sklearn notes: make_ Blobs generate clustering data
Pytorch模型训练到哪里找预训练模型?
Resizekit2.net size and resolution independent
MySQL function
Cookie加密10
Kubernetes core object overview details
Varnish foundation overview 1
JS prototype and prototype chain (Lantern Festival meal)
Cookie encryption 15 login encryption
手势数字启蒙学习机
[binary tree] maximum binary tree II
Cub school learning: manual query and ADC in-depth use
Varnish 基础概览7
Chiffrement des cookies 8