字符串的展开
来源:互联网 发布:打点器数据端无法打开 编辑:程序博客网 时间:2024/06/06 00:18
</pre><p style="margin: 0px; padding: 0px; font-weight: bold; line-height: 56px;"><pre code_snippet_id="1761415" snippet_file_name="blog_20160714_1_8881116" name="code" class="html"><span style="font-size: 16px; font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);">来源</span>
#include<stdio.h>#include<stdlib.h>char A[100];int P = 0;void hanshu(char *a, int p1, int p2, int p3){int i = 0;char x, y;while (a[i]){if (a[i] == '-'){x = a[i - 1];y = a[i + 1];if ((y - x) == 1)//相邻{A[P++] = '\0';}else if ((y - x) <= 0)//小{A[P++] = '-';A[P++] = '\0';}else { //大if (p1 == 3) //填充星星{for (int i = 1; i <= (p2*(y - x - 1)); i++){A[P++] = '*';}A[P++] = '\0';}else{if (x <= '9'&&y <= '9'&&x >= '0'&&y >= '0')//数字{if (p3 == 1) //顺序输出{for (int i = 1; i <= (y - x - 1); i++){for (int j = 1; j <= p2; j++){A[P++] = x + i;}}A[P++] = '\0';}if (p3 == 2) //逆序输出{for (int i = 1; i <= (y - x - 1); i++){for (int j = 1; j <= p2; j++){A[P++] = y - i;}}A[P++] = '\0';}}else //字母{if (p1 == 1 && p3 == 1) //小写 顺序输出{for (int i = 1; i <= (y - x - 1); i++){for (int j = 1; j <= p2; j++){if (x < 'a') //本身是大写{A[P++] = x + i + 32;}else //本身小写{A[P++] = x + i;}}}A[P++] = '\0';}if (p1 == 2 && p3 == 1) //大写 顺序输出{for (int i = 1; i <= (y - x - 1); i++){for (int j = 1; j <= p2; j++){if (x < 'a') //本身是大写{A[P++] = x + i;}else //本身小写{A[P++] = x + i - 32;}}}A[P++] = '\0';}if (p1 == 1 && p3 == 2) //小写 逆序输出{for (int i = 1; i <= (y - x - 1); i++){for (int j = 1; j <= p2; j++){if (x < 'a') //本身大写{A[P++] = y - i + 32;}else //本身小写{A[P++] = y - i;}}}A[P++] = '\0';}if (p1 == 2 && p3 == 2) //大写 逆序输出{for (int i = 1; i <= (y - x - 1); i++){for (int j = 1; j <= p2; j++){if (x < 'a') //本身大写{A[P++] = y - i;}else //本身小写{A[P++] = y - i - 32;}}}A[P++] = '\0';}}}}}i++;}}void main(){int p1 = 0, p2 = 0, p3 = 0;char a[100];for (int i = 0; i < 100; i++)A[i] = 0;scanf("%d%d%d", &p1, &p2, &p3);scanf("%s", &a);hanshu(a, p1, p2, p3);int i = 0;P = 0;while (a[i]){if (a[i] == '-'){while (A[P]){printf("%c", A[P]);P++;}P++;}else{printf("%c", a[i]);}i++;}}
0 0
- 字符串的展开
- 字符串的展开
- 字符串的展开
- 字符串的展开
- 【b702】字符串的展开
- P1098 字符串的展开
- 字符串的展开
- 字符串的展开
- 字符串的展开
- 35:字符串的展开
- B: 字符串的展开
- 35:字符串的展开
- [洛谷1098]字符串的展开
- 算法训练 字符串的展开
- 洛谷 P1098 字符串的展开
- 洛谷1098 字符串的展开
- 洛谷1098 字符串的展开
- 洛谷 P1098 字符串的展开
- 虚拟机联网和互ping的问题
- LeetCode - 90. SubsetsII
- 集训第八天
- jQuery:bind方法的使用详解
- python实现模拟按键,自动翻页看u17漫画
- 字符串的展开
- JAVA设计模式--代理模式(动态)(二)
- ListView的使用方法总结
- 关于editText.setOnFocusChangeListener不起作用
- vc 不重启改ip
- AspectJ学习过程
- 【LoadRunner】Web(HTTP/HTML)协议的关联
- 快学Scala第18章----高级类型
- 安卓中文组