- 1、本文档共45页,可阅读全部内容。
- 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
2791矩形覆盖题目描述
程序设计实习2007 程序设计实习 习题课 /cpp2010 2951 95.123 12 0.4321 20 5.1234 15 6.7592 9 98.999 10 1.0100 12 2951 思路:以95.123 12为例 求出小数部分长度 – 3位 去掉小数点,变成整数95.123 - 95123 求95123^12 = 548815620517731830194541899025343415715973535967221869852721 重新点小数点548815620517731830194541.899025343415715973535967221869852721 2951 代码 #includestdio.h #includestring.h const int MAX=100; char s[7]; int a[MAX],e,p,b,be,en,i; void mul() { int i,w=0; for(i=0;iMAX;i++) { a[i]=a[i]*b+w; w=a[i]/10; a[i]=a[i]-w*10; } } int main() { while (scanf(%s %d,s,e)!=EOF) { memset(a,0,sizeof(a)); b=0; //Step 1 and Step 2 for(i=0;istrlen(s);i++) if (s[i]==.) p=strlen(s)-i-1; else b=b*10+s[i]-0; a[0]=1; //Step 3 for(i=0;ie;i++) mul(); p*=e; //Step 4 for (be=MAX-1;a[be]==0be=p-1;be--); for (en=0;a[en]==0enp;en++); for (i=be;i=p;i--) printf(%d,a[i]); if (enp) printf(.); for (i=p-1;i=en;i--) printf(%d,a[i]); printf(\n); } return 0; } 2775 文件结构图 file1 file2 dir3 dir2 file1 file2 ] ] file4 dir1 ] file3 * file2 file1 * # 2775 关键:用什么样数据结构存储“文件结构图” struct DIR { char name[20]; int nf; int parent; char* files[MAXF]; bool children[MAXD]; } dirs[MAXD]; 2775 思路: 1.读入数据,生成dirs[ ] 2.遍历dirs[ ],输出结果 技术问题: 一个文件或者目录的父(上层)目录一定是最近的没有被”]”闭合的目录 #include iostream #include cstdio #include cstring using namespace std; #define MAXD 200 #define MAXF 200 struct DIR { char name[20]; int nf; int parent; char* files[MAXF]; bool children[MAXD]; } dirs[MAXD]; int current = 0; int parent = 0; int data_set = 1; void new_dir(int x, char* tmp, int p) { sprintf(dirs[x].name, %s, tmp); dirs[x].nf = 0; dirs[x].parent = p; memset(dirs[x].children, false, sizeof(dirs[x].children)); } void clear() { current = 1; parent = 0; new_dir(0, ROOT, -1); } void insert_file(int parent, char* tmp) { dirs[parent].files[dirs[parent].nf] = new char[20]; strcpy(dirs[parent].files[dirs[parent].nf], tmp); dirs[parent].nf++; } void format
文档评论(0)