上一页 1 ··· 6 7 8 9 10 11 12 13 14 15 下一页
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1222是经典的求最大公约数的例子~~代码如下: 1 #include <cstdio> 2 using namespace std; 3 4 long long m, n; 5 6 long gcd(long m, long n) 7 { 8 if(m < n) 9 {10 m = m - n;11 n = m + n;12 m = n - m; 13 } 14 if(n == 0)15 ... 阅读全文
posted @ 2012-08-18 21:18 山路水桥 阅读(151) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2090Windows下的EOF结束符为Ctrl + Z代码如下: 1 #include <cstdio> 2 using namespace std; 3 4 int main() 5 { 6 double num, price; 7 char s[20]; 8 double sum = 0; 9 while(scanf("%s %lf %lf", s, &num, &price) != EOF)10 {11 sum += num ... 阅读全文
posted @ 2012-08-18 21:17 山路水桥 阅读(333) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2043代码如下: 1 #include <cstdio> 2 #include <cstring> 3 using namespace std; 4 5 int main() 6 { 7 int a[4]; 8 char s[51]; 9 int t, flag;10 while(scanf("%d", &t) != EOF)11 {12 for(int i = 0; i < t; i++)13 {14 ... 阅读全文
posted @ 2012-08-18 21:15 山路水桥 阅读(264) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2071很少见到这样的水题了,连自己也变水了~~~代码如下: 1 #include <cstdio> 2 using namespace std; 3 4 int main() 5 { 6 int n; 7 int t; 8 double stu, max; 9 while(scanf("%d", &t) != EOF)10 {11 for(int j = 0; j < t; j++)12 {13 ... 阅读全文
posted @ 2012-08-18 21:14 山路水桥 阅读(258) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1084应用系统自带的排序就可以轻松解决~~代码如下: 1 #include <cstdio> 2 #include <cstring> 3 #include <cstdlib> 4 using namespace std; 5 6 typedef struct 7 { 8 int solve; 9 int score;10 int time;11 int order; 12 } data;13 14 data s[101];15 16 ... 阅读全文
posted @ 2012-08-18 21:12 山路水桥 阅读(317) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1049直接贴代码:View Code 1 #include <cstdio> 2 using namespace std; 3 4 int main() 5 { 6 int n, u, d; 7 int m; 8 while(scanf("%d%d%d", &n, &u, &d) != EOF && n != 0) 9 {10 m = (n - d) / (u - d);11 if((n-d)%(u-d) != 0)12 ... 阅读全文
posted @ 2012-08-18 21:10 山路水桥 阅读(100) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1202直接贴代码: 1 #include <cstdio> 2 using namespace std; 3 4 int credit(double p) 5 { 6 if(p >= 90) 7 { 8 return 4; 9 } 10 else if(p >= 80)11 {12 return 3; 13 }14 else if(p >= 70)15 {... 阅读全文
posted @ 2012-08-18 21:08 山路水桥 阅读(199) 评论(0) 推荐(0) 编辑
摘要: memset()位于头文件string.h中,用法是将一个字节一个字节的设置为某个数.,例如:memset(a, 0, sizeof(a)), a为数组,就是将a中的每一个字节都赋值为0。以前没有正确理解memset()的用法,将数组赋值为1时,用memset(a, 1, sizeof(a)), 导致出现很怪的数字。把一个int的每个字节都设置为1,也就是0×01010101,十进制就是16843009而在全部置0或者-1就没事。这是因为:设置为0 就是0×00000000设置-1就是FF,所以每个字节都置为-1就是0xFFFFFFFF,还是-1。这也是为何可以置0和置1的 阅读全文
posted @ 2012-08-18 10:09 山路水桥 阅读(526) 评论(0) 推荐(0) 编辑
摘要: 结构:?structnode{intflag;node *next[27];}*head;生成节点:?/*动态分配内存*/node * newnode(){inti;node * p = newnode; // c语言用(node * )malloc(sizeof(node), 这里是动态分配内存,... 阅读全文
posted @ 2012-08-18 00:47 山路水桥 阅读(105) 评论(0) 推荐(0) 编辑
摘要: 并查集结构:?for(i = 0; i rank[y] ) parent[y] = x;else{parent[x] = y;if( rank[x] == rank[y] ) ++rank[y];}} 阅读全文
posted @ 2012-08-18 00:46 山路水桥 阅读(145) 评论(0) 推荐(0) 编辑
上一页 1 ··· 6 7 8 9 10 11 12 13 14 15 下一页