首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

2014年华为上机机试c语言标题和答案

2013-10-08 
2014年华为上机机试c语言题目和答案自己code出来的,结果是正确的,但是其中还有很多的优化之处,还请各位大

2014年华为上机机试c语言题目和答案

自己code出来的,结果是正确的,但是其中还有很多的优化之处,还请各位大神多多指导。

代码打包: http://download.csdn.net/detail/sxlwzl/6259411


1.字符串过滤 stringFilter

去重过滤,例子:
"abcdabefe"-->"abcdef"


2.字符串压缩   stringZip
"aaaabbccccddeeeeef"-->"4a2b4c2d5ef"


3.表达式,100以内的正整数,加减运算
"4 + 7"-->"11"
"2 - 7"-->"-5"

"2 ++ 7"-->"0"  //注意:非法运算


2014年华为上机机试c语言标题和答案

ex1.h

#include <stdio.h>#include <stdlib.h>#include <string.h>#include "ex1.h"#include "ex2.h"#include "ex3.h"int main(){    printf("Enter main()\n");    char option;puts("\nex1:");puts("1.字符串过滤 stringFilter");puts("去重过滤,例子:");puts("\"abcdabefe\"-->\"abcdef\"");do{stringFilter();printf("if you want try anohter test, please input 'y' or input 'n'.\n");fflush(stdin);option = getchar();fflush(stdin);}while(option == 'y' || option == 'Y');puts("\nex2:");puts("2.字符串压缩   stringZip");puts("\"aaaabbccccddeeeeef\"-->\"4a2b4c2d5ef\"");do{stringZip();printf("if you want try anohter test, please input 'y' or input 'n'.\n");fflush(stdin);option = getchar();fflush(stdin);}while(option == 'y' || option == 'Y');    puts("\nex3:");    puts("3.表达式,100以内的正整数,加减运算");    puts("\"4 + 7\"-->\"11\"");    puts("\"2 - 7\"-->\"-5\"");    puts("\"2 ++ 7\"-->\"0\"");    do{my_calc();printf("if you want try anohter test, please input 'y' or input 'n'.\n");fflush(stdin);option = getchar();fflush(stdin);}while(option == 'y' || option == 'Y');    return 0;}




1楼u01176077648分钟前
请问楼主是哪个学校的啊?
Re: sxlwzl31分钟前
回复u011760776n暂时保密,还请多指教哈。

热点排行