1. The board put food
intLszl =1; for(inti =1; I < -; i++) { intx =1; for(intj =1; J <= I; J + +) {x= x *2; } Lszl= Lszl +x; } DoubleZL = Lszl *0.001; Console.WriteLine ("to fill the entire chessboard:"+ ZL +"kg of grain");
2. Hundred Chicken Hundred Money
for(inti =1; I < -; i++) { for(intj =1; J < -; J + +) { for(intK =1; K < $; k++) { DoubleA = i*2+j*1+k*0.5; if(A = = -) {Console.WriteLine ("buy a big chicken:"+i+"only, Chick"+j+"only, young chickens."+k+"only"); } } } }
3. A sheet of paper thickness is 0.1 mm, assuming this paper can be limited to fold, ask how many times can be more than Everest? 8848 m
intA =1; Doublez =0.0001; for(inti =1; I <= i+1; i++) {Z= Z *2; if(Z >8848) {a=i; Break; }} Console.WriteLine ("folded"+ A +"times can be as high as Mt. Everest .");
For Loop statement Board put grain, hundred chicken hundred money, paper folding problem