摘要: Greated Common Divisorint GCD(int a, int b){ int temp; if(a < b) { temp = a; a = b; b = temp; } if(a % b == 0) return b; return GCD(b, a % b);}Least Common Multiple//最小公倍数等于两数之积除以最大公约数 int LCM(int a,int b){ return (a * b) / GCD(a, b); } 阅读全文
posted @ 2013-11-04 15:49 alexeyqian 阅读(169) 评论(0) 推荐(0) 编辑
摘要: include leap yearint dayOfYear(int year, int month, int day){ int months[13] = {0,31,30,28,31,30,31,31,30,31,30,31}, i, days = 0; if( (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) // is leap year months[2] = 29; for(i = 1; i < month; i++) days += months[i]; days ... 阅读全文
posted @ 2013-11-04 15:35 alexeyqian 阅读(222) 评论(0) 推荐(0) 编辑
摘要: string end with '#'void reversePrint(){ char c; scanf("%c", &c); if(c != '#') reversePrint(); if(c != '#') printf("%c", c);} 阅读全文
posted @ 2013-11-04 15:22 alexeyqian 阅读(749) 评论(1) 推荐(0) 编辑