摘要: 放了一个长长的暑假,可能是这辈子最后一个这么长的暑假了吧,呵呵。。。今天来实验室了,先找了zoj上面简单的题目练练手直接贴代码了,不解释,就是一道简单的密文转换问题:#include #include int main(){ char cText[1000]; char start[10]; char end[5]; while(scanf("%s",start)!=EOF&&strcmp(start,"ENDOFINPUT")!=0) { getchar(); gets(cText); scanf("%s",end) 阅读全文
posted @ 2013-09-04 11:04 xlturing 阅读(267) 评论(0) 推荐(0) 编辑
摘要: 这道题目最让人头疼的就是该题的input怎么结束,因为它要求输入一个空行的时候则一串字符串输入结束,这就不得不让人绕个弯来解决这个问题。(注:本人习惯于使用C中的字符串操作,但是用到map要求使用string所以小绕弯)#include #include #include #include #include #include using namespace std;int main(){ map dic; map::iterator iter; char teng[15],tfm[15]; char tmp[25]; int n=0; while(gets(tmp)) { if(!strcm. 阅读全文
posted @ 2013-09-04 11:02 xlturing 阅读(356) 评论(0) 推荐(0) 编辑
摘要: 这道题目很简单,考察的就是结构体数组的应用,直接贴代码了#include #include typedef struct color{ int r; int g; int b;}color;double distance(color c1,color c2){ return sqrt(pow((c1.b-c2.b),2)+pow((c1.g-c2.g),2)+pow((c1.r-c2.r),2));}int equal(color c1,color c2){ if(c1.r==c2.r&&c1.g==c2.g&&c1.b==c2.b) return 1; els 阅读全文
posted @ 2013-09-04 10:58 xlturing 阅读(374) 评论(0) 推荐(0) 编辑
摘要: 这道题目说白了是一道平面几何的数学问题,重在理解题目的意思:题目说,弗雷德想买地盖房养老,但是土地每年会被密西西比河淹掉一部分,而且经调查是以半圆形的方式淹没的,每年淹没50平方英里,以初始水岸线为x轴,平分半圆为y轴,建立如下图的坐标系问题:给出坐标点(y>0),让你判断在那一年这个坐标点会被淹没。解决方案:我们可以转换成的数学模型是来比较坐标点到原点的距离与半圆半径的大小即可知道该点是否被淹没,公式如下:1.由于每年半圆面积增长50平方英里,可得半径递推公式R2=sqrt(100/pi+R1*R1) 注:初始R1设置为0,则把最开始情况包括进去。2.计算机坐标到原点的距离,就是勾股定 阅读全文
posted @ 2013-09-04 10:57 xlturing 阅读(709) 评论(0) 推荐(0) 编辑
摘要: 我承认这是一道水的不能再水的题,今天一下就做到了,还是无耻的帖上来吧#include int main(){ double sum=0; for(int i=1;i<13;i++) { double tmp=0; scanf("%lf",&tmp); sum+=tmp; } printf("$%.2lf\n",sum/12); return 0;} 阅读全文
posted @ 2013-09-04 10:56 xlturing 阅读(223) 评论(0) 推荐(0) 编辑
摘要: #include int main(){ float c; int i; while(scanf("%f",&c)!=EOF&&c) { float sum=0; for(i=2;sum<c;i++) { sum+=(1.0/i); } printf("%d card(s)\n",i-2); } return 0;} 简单不多说了 阅读全文
posted @ 2013-09-04 10:55 xlturing 阅读(208) 评论(0) 推荐(0) 编辑
摘要: 今天在ZOJ上做了道很简单的题目是关于加密解密问题的,此题的关键点就在于求余的逆运算:比如假设都是正整数 A=(B-C)%D 则 B - C = D*n + A 其中 A #include int main(){ int k,ccode[80]; char ptext[80],ctext[80]; while(scanf("%d",&k)!=EOF&&k) { scanf("%s",ctext); int n=0; while(ctext[n]!='\0') { if(ctext[n]=='.... 阅读全文
posted @ 2013-09-04 10:54 xlturing 阅读(289) 评论(0) 推荐(0) 编辑
摘要: ZOJ ACM题集,编译环境VC6.0#include int main(){ int a,b; while(scanf("%d%d",&a,&b)!=EOF) { printf("%d\n",a+b); } return 0;} 阅读全文
posted @ 2013-09-04 10:53 xlturing 阅读(237) 评论(0) 推荐(0) 编辑