就是翻转饼干的题目,代码写得不是很好,算了#include <iostream>#include <string>#include <algorithm>#include <sstream>#include <vector>//#include <iterator>//#include "boost/foreach.hpp"using namespace std;int main(){ //循环处理输入的每组字符串。每次循环一轮要输出最后的0和换行 for (string strLine; getlin Read More
posted @ 2012-07-07 23:34 godjob Views(154) Comments(0) Diggs(0)
//做这种题我知道了,以后数字能定多大就定多大,最后就long long int,前面都是把数字定义为int,老是WA#include <iostream>#include <string>#include <sstream>#include <algorithm>using namespace std;int main(){ string str1,str2,str3; while(cin>>str1>>str2>>str3) { unsigned long int p = 0; unsigned long Read More
posted @ 2012-06-30 22:46 godjob Views(234) Comments(0) Diggs(0)
没做,没感觉,做这类题提不起劲#include <stdio.h> #include <string.h> long long p[10001]; char num[10001]; int main() { long long i,j,k,len,n,mod; char lat[3]; while(scanf("%s%s%lld",num,lat,&n)!=EOF) { memset (p,0,sizeof(p)); len = strlen(num); for(i = 0;i <= len-1;i ++) ... Read More
posted @ 2012-06-28 22:53 godjob Views(186) Comments(0) Diggs(0)
这题没做,直接在网上看了别人的代码,对数字的一些问题不是很了解学习一下istringstream的用法:#include <iostream>#include <string>#include <sstream>//使用istringstream()需要调入的头文件using namespace std;string getMaxStr(){ int n=0x7fffffff; string s=""; while(n!=0) { s=(char)(n%10+'0')+s; n=n/10; } return s;}bool Read More
posted @ 2012-06-27 23:14 godjob Views(247) Comments(0) Diggs(0)
#include <iostream>#include <algorithm>#include <cstring>using namespace std;int mutil(char * x, char * y , char * z){ char * px = x; char * py = y; int carry =0 , temp; if(strcmp(x,"0") == 0 || strcmp(y,"0") == 0) { z[0] = 0; return 1; } int i,j; for(i = 0 ; *( Read More
posted @ 2012-06-27 21:53 godjob Views(140) Comments(0) Diggs(0)
水题,就是把非常大的数组进行相加#include <iostream>#include <algorithm>#include <cstring>using namespace std;char table_atoi[128];//下标字母 对应 数字int main(){ int i =0; char c = '0'; for( ; i < 10 ; ++i ,++c) { table_atoi[c] = i; } char buff[100]; char result[100] = {0}; char carry = 0; int Read More
posted @ 2012-06-25 22:51 godjob Views(199) Comments(0) Diggs(0)
该题有ANSI C写了一遍,通过使用二叉树的思想可以很好的解决这个问题,该题是用UVa系统测评的,发现如果用标准的C写代码的话,语法要求真的很严格,提交了几次都是语法错误,单行注释都报错,最要紧的是连内建的bool类型都没有,所以我用int型代替,下面是AC的代码#include <stdio.h>#define Nil -1char left[50], right[50], tree_index[50];char code[40];int top = 0;int tree_root = -1;char* out_buff_is = "Set %d is immediat Read More
posted @ 2012-06-25 17:20 godjob Views(244) Comments(0) Diggs(0)
Text-processing tools like awk and sed allow you to automatically perform a sequence of editing operations based on a script. For this problem we consider the specific case in which we want to perform a series of string replacements, within a single line of text, based on a fixed set of rules. Each Read More
posted @ 2012-06-24 23:17 godjob Views(227) Comments(0) Diggs(0)
Immediate DecodabilityAn encoding of a set of symbols is said to be immediately decodable if no code for one symbol is the prefix of a code for another symbol. We will assume for this problem that all codes are in binary, that no two codes within a set of codes are the same, that each code has at l. Read More
posted @ 2012-06-24 20:54 godjob Views(308) Comments(0) Diggs(0)
Artificial Intelligence?Physics teachers in high school often think that problems given as text are more demanding than pure computations. After all, the pupils have to read and understand the problem first!So they don't state a problem like ``U=10V, I=5A, P=?" but rather like ``You have an Read More
posted @ 2012-06-16 15:42 godjob Views(197) Comments(0) Diggs(0)