Poor lifting Iteration

Source: Internet
Author: User

//1, a 150 yuan shopping card, three types of washing supplies, shampoo 15 yuan, soap 2 yuan, toothbrush 5 yuan//please just spend 150 yuan, how many kinds of buying method, each buy a few ways? //shampoo x Soap Z toothbrush y intCount =0; intBian =0;  for(intx =0; X <=Ten; X + +) {        for(inty =0; Y <= -; y++)       {              for(intz =0; Z <= the; z++) {Bian++; if( the* x +5* y +2* Z = = Max) {Count++; Console.WriteLine ("Section"+ Count +"kind of Buy method shampoo"+ x +"bottle, body soap"+ z +"block, toothbrush"+ y +"Support"); } }}} Console.WriteLine ("it's circulating."+ Bian +"Times"); Console.WriteLine ("there are altogether"+ Count +"method of buying"); Console.ReadLine ();





 //rooster Two cents A, hen a penny, chicken half text money, now have 100 cents, to buy 100 chickens, //just spend 100 money, how many kinds of buying method, each kind of buy a few?  intCount =0; intBian =0;  for(intGong =0; Gong <= -; gong++) {      for(intMu =0; Mu <= -; mu++)     {           for(intXiao =0; Xiao <= $; xiao++) {Bian++; if(Gong + mu + Xiao = = -&& Gong *2+ mu *1+ Xiao *0.5== -) {Count++; Console.WriteLine ("Section"+ Count +"kind of buy French cocks"+ Gong +"only, hen"+ mu +"only, Chick"+ Xiao +"only"); } }}} Console.WriteLine ("it's circulating."+ Bian +"Times"); Console.WriteLine ("Total"+ Count +"method of buying"); Console.ReadLine ();





// For loop deform get while loop // The initial condition gets to the front, the loop state changes to the last sentence of the loop body // For a while, the original semicolon is removed, leaving only the loop condition // digital 1~10, summation sum int 0 ; int 1 ;  while Ten ) {     + = i;     I+ +;} Console.WriteLine (sum);

//rooster Two cents A, hen a penny, chicken half text money, now have 100 cents, to buy 100 chickens,//just spend 100 money, how many kinds of buying method, each kind of buy a few? Using the While loopintCount =0;intBian =0;intGong =0; while(Gong <= -){    intMu =0;  while(Mu <= -)    {         intXiao =0;  while(Xiao <= $) {Bian++; if(Gong + mu + Xiao = = -&& Gong *2+ mu *1+ Xiao *0.5== -) {Count++; Console.WriteLine ("Section"+ Count +"kind of buy French cocks"+ Gong +"only, hen"+ mu +"only, Chick"+ Xiao +"only"); } Xiao++; } mu++; } Gong++;} Console.WriteLine ("Total"+ Count +"method of buying"); Console.WriteLine ("It's a total cycle."+ Bian +"Times"); Console.ReadLine ();

// Iteration // paper thickness 0.07 mm // How many times can it be folded to 8848 meters above the Everest height Double 0 ; Double 0.07 ;  while 8848000 ) {    a++    ; 2 ;} Console.WriteLine (a);

//Big horse Camel 2 stone grain, medium horse camel 1 stone grain, two pony 1 stone grain, want to use 100 horse, camel 100 stone grain, how to distribute? intCount =0;intBian =0; for(intDM =0; DM <= -; dm++){      for(intZM =0; ZM <= -; zm++)     {           for(intXM =0; XM <= $; xm++) {Bian++; if(DM + ZM + XM = = -&& DM *2+ ZM *1+ XM *0.5== -) {Count++; Console.WriteLine ("Section"+ Count +"kind of way, big horse ."+ DM +"Horse , medium horse."+ ZM +"horse, pony."+ XM +"Horse"); }}}}console.writeline ("it's circulating."+ Bian +"Times"); Console.WriteLine ("there are altogether"+ Count +"kind of Method"); Console.ReadLine ();

//there are 1 cents, 2 cents, 5 cents of coins, to be combined out of 2 cents, there are several combinations, how many each? intCount =0;intBian =0; for(intYF =0; YF <= -; yf++){      for(intEF =0; EF <=Ten; ef++)     {           for(intWF =0; WF <=4; wf++) {Bian++; if(YF *1+ EF *2+ WF *5== -) {Count++; Console.WriteLine ("Section"+ Count +"type of combination 1 cent coin"+ YF +"one, 2 cents."+ EF +"one, 5 cents."+ WF +"a"); }}}}console.writeline ("Total"+ Count +"combination of methods"); Console.WriteLine ("It's a total cycle."+ Bian +"Times"); Console.ReadLine ();

//enter an integer within 100 to get from 1 to the number of the and if the number of inputs is not between 0 and 100, prompt please re-enter for (; ; ) {Console.Write ("Please enter an integer within 100:"); intA =int.    Parse (Console.ReadLine ()); intsum =0; if(A >=0&& a <= -)    {         for(inti =0; I <= A; i++) {sum+=i;        } Console.WriteLine (sum);  Break; }    Else{Console.WriteLine ("your input is wrong, please re-enter"); }}console.readline ();

  





Poor lifting Iteration

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.