一次做ACM扩展出来的小程序
2015-06-25 23:09
513 查看
这个小程序就是自己学习用的
第一次实践式的写一个程序,纪念一下,哈哈~~
程序功能描述:
0 - “_”
1 - “a”
2 - “b”
……….
25 - “y”
26 - “z”
27 - “.”
可以互相进行查询
第一次实践式的写一个程序,纪念一下,哈哈~~
程序功能描述:
0 - “_”
1 - “a”
2 - “b”
……….
25 - “y”
26 - “z”
27 - “.”
可以互相进行查询
#include <stdio.h> #include <stdlib.h> #include <string.h> int main() { int i, j = 0, length, code[28]; char str[1000]; //对code数组按照要求赋值 //"_" ASCII value is 95 //"." ASCII value is 46 //"a" ASCII valude is 97 code[0] = '_'; code[27] = '.'; for(i = 1; i < 27; i++) { code[i] = 'a' + i - 1; } printf("PS: \"-1\" means END!!\n"); printf("Please input the num or letter:<0-27 | a-z | \"_\"| \".\" only>\n"); while(scanf("%s", str)) { length = strlen(str); if(length == 1) { if((str[0] < 'a' || str[0] > 'z') && str[0] != '_' && str[0] != '.' && (str[0] < '0' || str[0] > '9')) { printf("Input Error! Input again:\n"); } else { for(i = 0; ; i++) { //char型数据处理 if((str[0] - 'a') >= 0) { if(code[i] == str[0]) { printf("The %c is %d\n", str[0], i); break; } } else if(str[0] == '_' || str[0] == '.') { if(str[0] == '_') { printf("The _ is %d\n", 0); break; } else if(str[0] == '.') { printf("The . is %d\n", 27); break; } } //int型数据处理 else if(i == atoi(str)) { printf("The %d is %c\n", i, code[i]); break; } } } } else if(length == 2) { //先处理正确的 // // //int型的两位数处理 if(((atoi(str) - 10) >= 0) && ((atoi(str) - 27) <= 0) && atoi(str) != -1) { for(i = 10; ; i++) { if(i == atoi(str)) { printf("The %d is %c\n", i, code[i]); break; } } } else if(atoi(str) == -1) { printf("The program ENDED!!\n"); return 0; } else { printf("Input Error! Input again!\n"); } } else { printf("Input Error! Input again!\n"); } } return 0; }
相关文章推荐
- iOS关于微信支付的一点小事
- 未来十年营销的主流趋势:微信营销
- 微信公众号二维码 链接
- android微信付费
- Iphone手机,微信调用支付JSAPI缺少参数 timeStamp
- 微信js接口自定义分享内容
- Android 超高仿微信图片选择器 图片该这么加载
- Android 高仿微信头像截取 打造不一样的自定义控件
- android高仿微信拍照、多选、预览、删除(去除相片)相册功能
- 定时采集指定微信公众号发布的文章!!终于搞定了!!哈哈
- 微信分享 添加URL Schemes
- PHP微信开发-------视频学习推荐
- 微信公众开发平台 手册
- Android笔记 ActionBar+Fragment+ViewPager实现仿微信首页滑动切换窗口
- 微信自定义菜单中文乱码问题
- 微信公众之智能硬件————序
- 源码推荐(6.5):照片编辑(滤镜,标签,卡片),类似微信右上角弹出式菜单控件
- Android中fragment选项卡功能(既可点击又可滑动,仿微信主界面)
- 6成假新闻来自微博 周二微信朋友圈谣言多
- 微信自定义菜单中文乱码问题