云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > 浙江大学计算机学院考研复试上机试题及参考答案

浙江大学计算机学院考研复试上机试题及参考答案

  • 62 次阅读
  • 3 次下载
  • 2025/5/4 14:23:50

num1 = 0; breakflag = 1; p = strtok(op1,\ while(p) /* 求出第一个输入火星数的数组 */ {

if( ( op1List[num1++] = atoi(p) ) != 0) breakflag = 0; p = strtok(NULL,\ }

if(breakflag) break; /* 第一个输入为0,退出循环;如果放到ZOJ2529,删除本行 */

num2 = 0; breakflag = 1; p = strtok(op2,\ while(p) /* 求出第二个输入火星数的数组 */ {

if( ( op2List[num2++] = atoi(p) ) != 0) breakflag =0;

p = strtok(NULL,\ }

if(breakflag) break; /* 第二个输入为0,退出循环;如果放到ZOJ2529,删除本行 */

num1--,num2--; /* preset num1 and num2 start from zero */

if(num1 < num2) /* 把输入的两个火星数数按位序对齐,两个if操作只执行一个 */

for(i = num1; i >= 0; --i) {

op1List[i + num2 - num1] = op1List[i]; op1List[i] = 0; }

if(num1 > num2)

for(i = num2; i >= 0; --i) {

op2List[ i + num1 - num2] = op2List[i]; op2List[i] = 0; }

cnt = (num1 > num2) ? num1 : num2; /* cnt为两个火星数的较大位数,便于确定输出位数 */

for( index=0, i=cnt; i>=0 ; i--, index++ ) {

num = op1List[i] + op2List[i] + OutputList[index];

if( num - PrimeList[index] >= 0 ) {

OutputList[index] = num - PrimeList[index]; OutputList[index+1]++;

if( index + 1 > cnt ) cnt++; /* 最高位进位 */ } else

OutputList[index] = num; }

while( OutputList[cnt]==0 && cnt ) cnt--; /* omit leading zeros */ for( ; cnt >=0 ; cnt-- )

printf(\(cnt==0)?'\\n':','); }while(1); return 0; }

?

2006年浙江大学计算机学院考研复试上机试题及参考答案(4/5) 第4题:简单计算器(7分)

题目要求:读入一个只包含 +, -, *, / 的正整数计算表达式,计算该表达式的值。

输入格式:测试输入包含若干测试用例,每个测试用例占一行,每行不超过80个字符,整数和运算符之间用一个空格分隔。没有非法表达式。当一行中只有0时输入结束,相应的结果不要输出。

输出格式:对每个测试用例输出1行,即该表达式的值,精确到小数点后2位。 输入样例: 1 + 2

4 + 2 * 5 - 7 / 11 0

输出样例: 3.00 13.36

#include #include #include #include

  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

num1 = 0; breakflag = 1; p = strtok(op1,\ while(p) /* 求出第一个输入火星数的数组 */ { if( ( op1List[num1++] = atoi(p) ) != 0) breakflag = 0; p = strtok(NULL,\ } if(breakflag) break; /* 第一个输入为0,退出循环;如果放到ZOJ2529,删除本行 */ num2 = 0; breakflag = 1; p = strtok(op2,\ while(p) /* 求出第二个输入火星数的数组 */ { if( ( op2List[num2++] = atoi(p) ) != 0) breakflag =0;

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com