摘要: http://poj.org/problem?id=3077念完题目也知道这题需要递归,当为要求的10的整数幂时返回,否则按四舍五入,再将幂加1,继续递归。 1 #include <stdio.h> 2 #include <math.h> 3 #include <stdlib.h> 4 void trans(int *p,int base) 5 { 6 if((*p)<(int)pow(10,base)) return; 7 if((*p)==pow(10,base)) return; 8 if((*p)>pow(10,base)) { 9 .. 阅读全文
posted @ 2013-02-05 16:17 linyvxiang 阅读(155) 评论(0) 推荐(0) 编辑
摘要: http://poj.org/problem?id=2305和2105一样的,练习库函数,注意itoa在g++下面是不存在的。 1 #include <stdio.h> 2 #include <string.h> 3 #include <stdlib.h> 4 #include <stack> 5 using namespace std; 6 int main() 7 { 8 int b; 9 char p[1020],m[10];10 while(scanf("%d",&b)!=EOF) {11 if(b==0) r 阅读全文
posted @ 2013-02-05 15:55 linyvxiang 阅读(152) 评论(0) 推荐(0) 编辑
摘要: http://poj.org/problem?id=2105看到有人写的博文,才知道的这个库函数,用一下,确实好用~strtol: string to long int 第一个参数为要转换的字符串的指针,第二个一般不用,为出错时返回的二级指针,第三个为字符串中数字的基数,而且对于大小写字母通吃. 1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <string.h> 4 int main() 5 { 6 char str[10]; 7 int N; 8 while(scanf("%d&quo 阅读全文
posted @ 2013-02-05 15:30 linyvxiang 阅读(169) 评论(0) 推荐(0) 编辑