1009: C语言程序设计教程(第三版)课后习题5.7
来源:互联网 发布:淘宝代理客服 编辑:程序博客网 时间:2024/05/04 02:39
学习如何讲述倒序输出
题目描述
给出一个不多于5位的整数,要求 1、求出它是几位数 2、分别输出每一位数字 3、按逆序输出各位数字,例如原数为321,应输出123
输入
一个不大于5位的数字
输出
三行 第一行 位数 第二行 用空格分开的每个数字,注意最后一个数字后没有空格 第三行 按逆序输出这个数
样例输入
12345
样例输出
5
1 2 3 4 5
54321
#include<stdio.h>#include<string.h>#define N 5int main(){ char num[N]; scanf("%s", num); int len = strlen(num); int i = 0, test = 0; printf("%d\n", len); for(; i<len; i++){ if(test++){ printf(" "); } printf("%c", num[i]); } printf("\n"); for(i=len-1; i>=0; i--){ printf("%c", num[i]); } printf("\n"); return 0;}
0 0
- 1009: C语言程序设计教程(第三版)课后习题5.7
- C语言程序设计教程(第三版)课后习题5.7
- 1052: C语言程序设计教程(第三版)课后习题11.5
- 1052: C语言程序设计教程(第三版)课后习题11.5
- 1001: C语言程序设计教程(第三版)课后习题1.5
- 1003: C语言程序设计教程(第三版)课后习题3.7
- 1005: C语言程序设计教程(第三版)课后习题4.9
- 1007: C语言程序设计教程(第三版)课后习题5.5
- 1010: C语言程序设计教程(第三版)课后习题5.8
- 1051: C语言程序设计教程(第三版)课后习题11.5
- 1052:C语言程序设计教程(第三版)课后习题11.8
- C语言程序设计教程(第三版)课后习题11.8
- C语言程序设计教程(第三版)课后习题10.4
- 1002: C语言程序设计教程(第三版)课后习题1.6
- 1003: C语言程序设计教程(第三版)课后习题3.7
- 1004: C语言程序设计教程(第三版)课后习题4.8
- 1005: C语言程序设计教程(第三版)课后习题4.9
- 1006: C语言程序设计教程(第三版)课后习题5.4
- 安装pygraphviz遇到的问题解决办法。
- 动态规划,矩阵最小路径和
- 设计模式-4-单例模式
- One hot encoding
- React Native 解决iOS上键盘遮挡TextInput问题
- 1009: C语言程序设计教程(第三版)课后习题5.7
- 自定义控件
- LeetCode笔记:226. Invert Binary Tree
- tsiLdekniLaniedoNeteleD.237
- [leetcode] 317. Shortest Distance from All Buildings 解题报告
- Scratch 介绍及入门
- dddd
- IOS NSString 操作
- POJ 2287 田忌赛马 贪心