摘要: 给定一个IP要求判断是否为正确IP。这里用sscanf进行处理较为方便。在数据末尾添加一个tail字符来判定是否还有缀余字符,利用到该函数的返回值。 #include <cstdio>#include <cstring>#include <cstdlib>using namespace std;bool r( int x ){ return x>= 0&& x<= 255? 1: 0;}int main(){ char ip[105]; while( gets( ip ) ) { int a, b, c, d, len= strl 阅读全文
posted @ 2011-08-16 22:34 沐阳 阅读(473) 评论(2) 推荐(0) 编辑
摘要: 题义:给定一个数字串,求出这些串的第K小组合串。 代码如下:#include <cstdio>#include <algorithm>using namespace std;int num[1005];int main( ){ int N, M; while( scanf( "%d %d", &N, &M )!= EOF ) { for( int i= 1; i<= N; ++i ) { num[i]= i; } while( --M ) { next_permutation( num+ 1, num+ N+ 1 ); } fo 阅读全文
posted @ 2011-08-16 14:22 沐阳 阅读(284) 评论(0) 推荐(0) 编辑
摘要: BillboardTime Limit: 20000/8000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1619Accepted Submission(s): 809Problem DescriptionAt the entrance to the university, there is a huge rectangular billboard of size h*w (h is its height and w is its width). The board is the 阅读全文
posted @ 2011-08-16 11:17 沐阳 阅读(589) 评论(0) 推荐(0) 编辑