2012年11月8日

UVA10562 - Undraw the Trees

摘要: 又是递归函数的简单应用。思路较简单,卡到我的地方是我定义的二维数组来读取数据,但是开始的时候我认为每行宽度都相同,后来我才发现每行的宽度不一定相同,我便定义了一个数组,用来记录每行的宽度,此题编过。代码如下:#include #include using namespace std; char ch[250][250]; int deep, w[250];//记录各行的宽度 void go(int k, int i, int j) { int left, right; cout0?left+1:0), (right>n,cin.ignore(); while(n--... 阅读全文
posted @ 2012-11-08 22:59 Primo... 阅读(145) 评论(0) 推荐(0)

UVA839 - Not so Mobile

摘要: 题目较为简单,不做多余解释,递归函数的简单应用代码如下:#include using namespace std; int cacult(int &qual) { int w1, d1, w2, d2, temp; if(cin>>w1>>d1>>w2>>d2 == 0)return -1; if(!w1) w1 = cacult(temp); if(!w2) w2 = cacult(temp); if(w1*d1 == w2*d2&&temp)qual = 1; else qual = 0; retu... 阅读全文
posted @ 2012-11-08 21:20 Primo... 阅读(126) 评论(0) 推荐(0)

UVA327 - Evaluating Simple C Expressions

摘要: 题目很简单,不过需要考虑全面才可、个人觉得题目表达的不是很准确,其中没有考虑到a与--之间有空格的情况就是我第一次RTE的原因所在】因此,我先进行空格剔除,在进行其他操作。代码如下:#include #include #include using namespace std; int ch[30], sum, length; string s; int cacultor(int a, char c, int b)//计算函数 { switch (c) { case '+': return a+b; case '-': ret... 阅读全文
posted @ 2012-11-08 00:13 Primo... 阅读(192) 评论(0) 推荐(0)