码迷,mamicode.com
首页 >  
搜索关键字:for while until    ( 29426个结果
hdu 2602 Bone Collector
开始变量竟然输反了#include #include int dp[1002]; struct none { int vo; int value; }a[1002]; int max(int a,int b) {return a>b?a:b;} int main() { int N,V,T,i,j; scanf("%d",&T); while(T--) { sc...
分类:其他好文   时间:2014-07-25 11:28:01    阅读次数:203
uva 548(二叉树)
题解:给出了二叉树的中序和后序,重建二叉树,输出路径和最短的叶子的值。 两个模板: 给出前序和中序建树: Node* build (int n, int* preo, int* ino) { Node* node = new Node; int i = 0; if (n <= 0) return NULL; while (ino[i] != p...
分类:其他好文   时间:2014-07-25 11:26:21    阅读次数:175
Codeforces Round #258 (Div. 2/A)/Codeforces451A_Game With Sticks
解题报告 n和m跟木棍相交,问一人取一交点(必须是交点,且取完后去掉交点的两根木棍),最后谁赢 思路: 取最大正方形,以对角线上的交点个数判断输赢。 #include #include using namespace std; int main() { int m,n; while(cin>>n>>m) { if(n>m) {...
分类:其他好文   时间:2014-07-25 11:18:01    阅读次数:288
USACO Section 2.1 Healthy Holsteins
/* ID: lucien23 PROG: holstein LANG: C++ */ #include #include #include using namespace std; bool compFun(int x, int y) { int temp, i = 0; while (true) { temp = 1 < temp&y...
分类:其他好文   时间:2014-07-24 23:11:33    阅读次数:433
P77 ~
#include int q1,q2,q3; void fun(long n) { q1=q2=q3=0; while(n) { switch(n%10) { case 1:q1++;break; case 2:q2++;break; case 3:q3++; } n/=10; } } main() { long n=123451123; fun(n); ...
分类:其他好文   时间:2014-07-24 23:04:43    阅读次数:271
剑指Offer:二进制中1的个数
题目:输入一个整数,输出该数二进制表示中1的个数。// 二进制中1的个数#include int wrong_count_1_bits(int n) // 错误解法: 当n为负数时, n>>=1右移, 最高位补1, 陷入死循环{ int count = 0; while(n) { ...
分类:其他好文   时间:2014-07-24 22:33:42    阅读次数:221
switch 与 whille相互套用
一直自以为还比较了解C++,这两天写个小工具结果出现了个bug,查了几个小时。现在才发现我这么水。switch是C++后来推出了,目的在于提高代码结构清晰度。但是switch与while连用时是有坑的。 1 #include 2 #include 3 4 int main() 5 { 6 ...
分类:其他好文   时间:2014-07-24 22:17:32    阅读次数:236
hdu 2037 今年暑假不AC
http://acm.hdu.edu.cn/showproblem.php?pid=2037贪心的题,按结束时间来贪心,结束时间尽可能提前,看得节目就尽可能多了。注意审题,题目说不止一组数据就得写好循环while(scanf("%d",&n)!=EOF)等价于while(~scanf("%d",&n...
分类:其他好文   时间:2014-07-24 22:14:02    阅读次数:216
hdoj 1050 moving tables
代码:#include #include //#include usingnamespacestd;intf[201];intmain(){//ifstreamcin("1050_input.txt");//调试用 intt,n,i,j,s,e;cin>>t;while(t--){memset(f,...
分类:其他好文   时间:2014-07-24 22:12:42    阅读次数:185
d4_1 字符长度
#includevoid main(){char name[10];int i=0;printf("Enter your name:");scanf("%s",name);printf("Spell it:");while(name[i]!='\0'){ printf("%c ",name[i...
分类:其他好文   时间:2014-07-24 21:25:19    阅读次数:186
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!