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

算法设计思路
- 定义数字字母列表
- 使用get方法读取字符串,并进行单个字符转数字相加得到值n
- 遍历n值,将n的各个位数保持在列表t中
- 通过列表t中的值进行数字字母列表的打印
代码
#include <stdio.h>
#include <string.h>
int main(){
char c [105];
int a [5];
char pinyin[][9] = {
"ling", "yi", "er", "san", "si", "wu", "liu", "qi", "ba", "jiu"};
int i, n, t;
n = 0;
t = 0;
gets(c);
for(i=0; i<strlen(c); i++){
n += c[i] - '0';
}
while(n != 0){
a[t] = n % 10;
n = n / 10;
t++;
}
printf("%s", pinyin[a[t-1]]);
for(i=t-2; i>=0; i--){
printf(" %s", pinyin[a[i]]);
}
return 0;
}
运行结果

边栏推荐
- Questions about database: database attachment
- cookie加密11
- R language linear regression model fitting diagnosis outliers analysis of domestic gas consumption and calorie examples with self-test questions
- How to build your own blog website by yourself
- 关于c语言main函数中int argc,char **argv的理解
- 【图神经网络】图分类学习研究综述[3]:图分类方法评价及未来研究方向
- Wechat applet - requestsubscribemessage:fail can only be invoked by user tap gesture
- VIM编辑器常用指令
- Seata and the three platforms are working together in the summer of programming. Millions of bonuses are waiting for you
- C language selection, loop overview
猜你喜欢

cookie加密8

Interface Association of postman

Ansible ad-hoc 临时命令

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

Application of pointer in STC89C52 single chip microcomputer and demonstration of practical cases

Quality management of functional modules of MES management system
![Cantilever beam calculation [matlab code]](/img/f6/9a1338e00777e91f6c340eae9d52ba.jpg)
Cantilever beam calculation [matlab code]

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

The first unlucky person watching eth 2.0

Seata 與三大平臺攜手編程之夏,百萬獎金等你來拿
随机推荐
How does webapi relate to the database of MS SQL?
81. 搜索旋转排序数组 II
How to seamlessly transition from traditional microservice framework to service grid ASM
Seata and the three platforms are working together in the summer of programming. Millions of bonuses are waiting for you
MySql函数
Varnish 基础概览8
Ansible ad-hoc temporary command
I, 33 years old, ByteDance test development, unveiled the real income of Beijing "test post"
Interview summary
3-6sql injection website instance step 5: break through the background to obtain web administrator permissions
Equivalence class partition method for test case design method
The listing of Symantec electronic sprint technology innovation board: it plans to raise 623million yuan, with a total of 64 patent applications
Solving plane stress problem with MATLAB
田口实验法
ctfshow 大赛原题 680-695
HC32M0+ GPIO
Machinery -- nx2007 (UG) finite element analysis tutorial 1 -- simple object
cookie加密9
Understand the module function of MES management system
Cookie加密15 登录加密