ImageVerifierCode 换一换
格式:DOCX , 页数:7 ,大小:18.17KB ,
资源ID:9849758      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bingdoc.com/d-9849758.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(ACMICPC南太平洋赛区试题解析1.docx)为本站会员(b****8)主动上传,冰点文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰点文库(发送邮件至service@bingdoc.com或直接QQ联系客服),我们立即给予删除!

ACMICPC南太平洋赛区试题解析1.docx

1、ACMICPC南太平洋赛区试题解析12003年ACM-ICPC南太平洋赛区试题解析-1 ACM国际大学生程序设计竞赛由国际计算机学界著名的ACM学会(Association for Computer Machinery)主办,是世界上规模最大、水平最高的国际大学生程序竞赛。本文作为CSTC团队之ACM培训的启动工程训练内容,请从此题入手,开始你们痛并快乐着的ACM之旅。 此题虽为ACM比赛用题,却非常简单,没有什么特别之处,不牵扯数据结构,实为初学者建立自信心的灵丹妙药。 英文原文 P1 - ACM SPPC 1 of 2 Saturday, 20/09/2003 PROBLEM 1 - WA

2、CMIAN NUMBERS In the supposedly uninhabited Wacmahara Desert, a tribe of unusual people has been discovered. The Wacmians have only 2 fingers and a thumb on each hand, and have invented their own numbering system. The digits they use and the symbols they use for digits are quite unusual, but anthrop

3、ologists have been able to represent them as follows: % represents 0 ) represents 1 represents 2 represents 3 ? represents 4 represents 5 $ represents -1 (yes, they even have a negative digit) As you may expect, their system is base 6 where each place value is 6 times the value to its right, as in t

4、he following examples: )% is 1*62+3*6+0 = 36+18+0 = 54 ?$ is 4*63+(1)*62+2*6+2 = 86436+12+2 = 842 $ is (1)*62+2*6+2 = 36+12+2 = -22 Your task is to take Wacmian numbers and represent them as standard base 10 numbers. P1 - ACM SPPC 2 of 2 Saturday, 20/09/2003 INPUT FORMAT Input consists of Wacmian nu

5、mbers, one per line. Each number consists of a sequence of 1 to 10 Wacmian digits. A single # on a line by itself indicates the end of input. SAMPLE INPUT: )% ?$ $ % # OUTPUT FORMAT Output will be the corresponding decimal numbers, one per line. SAMPLE OUTPUT: 54 842 -22 0 这里我们提供出来本题的中文对照: Wacmian 数

6、字 在假设的Wacmahara无人沙漠里,一个非普通人组成的部落被发现了。Wacmians的每个手上仅有两个手指和一个拇指,并且他们发明了自己的数字系统。他们使用的数字和用来表示数字的符号都很奇特,但是人类学家已经能够以用下面的方法描述它们: % - 0 ) - 1 - 2 - 3 ? - 4 - 5 $ - -1 (没错,他们甚至有负数) 如你所愿,他们的系统是以6为基础的,每位上的数值达到6就像该位的左边进位,如同随后的例子: )% 表示 1*62+3*6+0 = 36+18+0 = 54 ?$ 表示 4*63+(-1)*62+2*6+2 = 864-36+12+2 = 842 $ 表示

7、(-1)*62+2*6+2 = -36+12+2 = -22 你的任务是把Wacmian数字解释成标准的10进制数字。 输入格式 输入包括Wacmian数字,每行一个。每个数字由1至10个有顺序的Wacmian数字组成。一个单独的#占用一行,它标志输入结束。输入举例: )% ?$ $ % # 输出格式 输出相应的是进制数字,每行一个。 输出举例: 54 842 -22 0本题的解答如下: #include #include int GetData(int *digit,FILE *fp) char temp; int i=0; /使用temp记录从input.in文件中逐个读出的字符 temp

8、 = fgetc(fp); /如果为回车符,表示该数的读取已经结束了 while(temp !=n) switch (temp) case %: digiti = 0;break; case ): digiti = 1;break; case : digiti = 2;break; case : digiti = 3;break; case ?: digiti = 4;break; case /: digiti = 5;break; case $: digiti = -1;break; case #: return -1; / 让函数返回 -1 表示input.in文件结束 /digit10用

9、来统计数中的位数 digit10 = i+1; i+; /数组下标增加 1 /读入下一个字符 temp = fgetc(fp); return 0; void main() /题目中给每个数最多只有10位 /所以数组定义11位 /前10位保存每位的数字 /最后一位统计位数 int digit11; long number = 0; /考虑到极值状况,采用long类型 long temp = 1; int i,j; FILE *fpInput,*fpOutput; fpInput = fopen( input.in,r); fpOutput = fopen(output.out,w); digi

10、t10 = 0; while(GetData(digit,fpInput) != -1) for(i=0; idigit10; i+) for(j=0; jdigit10-i-1; j+) temp *= 6; number += (digiti*temp); temp = 1; /将每一位转换成10进制后都需要为temp初始化 /以便下一位的转换时使用 fprintf(fpOutput,%ldn,number); number = 0; /每个数字转换完成后number同样需要重新初始化 fclose(fpInput); fclose(fpOutput); posted on 2004-06

11、-12 19:57 monkeyking 阅读(790) 评论(1) 编辑收藏 引用 网摘 所属分类: 原创 FeedBack: # 2003年ACM-ICPC南太平洋赛区试题解析-12004-09-13 16:43 | lili#include #include intGetData(int*digit,FILE*fp) chartemp; inti=0; /使用temp记录从input.in文件中逐个读出的字符 temp=fgetc(fp); /如果为回车符,表示该数的读取已经结束了 while(temp!=n) switch(temp) case%:digiti=0;break; cas

12、e):digiti=1;break; case:digiti=2;break; case:digiti=3;break; case?:digiti=4;break; case/:digiti=5;break; case$:digiti=-1;break; case#:return-1;/让函数返回-1表示input.in文件结束 /digit10用来统计数中的位数 digit10=i+1; i+;/数组下标增加1 /读入下一个字符 temp=fgetc(fp); return0; voidmain() /题目中给每个数最多只有10位 /所以数组定义11位 /前10位保存每位的数字 /最后一位统

13、计位数 intdigit11; longnumber=0;/考虑到极值状况,采用long类型 longtemp=1; inti,j; FILE*fpInput,*fpOutput; fpInput=fopen(input.in,r); fpOutput=fopen(output.out,w); digit10=0; while(GetData(digit,fpInput)!=-1) for(i=0;idigit10;i+) for(j=0;jdigit10-i-1;j+)temp*=6; number+=(digiti*temp); temp=1; /将每一位转换成10进制后都需要为temp初始化 /以便下一位的转换时使用 fprintf(fpOutput,%ldn,number); number=0;/每个数字转换完成后number同样需要重新初始化 fclose(fpInput); fclose(fpOutput);

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2