如何重复整个代码

时间:2015-11-30 19:24:16

标签: c# repeat

我想重复整个代码,但是就像你看到它会在第一个代码之后结束(对不起它是荷兰语)

int nummervanappels;
Console.Write ("hoeveel appels zijn er :");
nummervanappels = Convert.ToInt16 (Console.ReadLine());
if (nummervanappels == 15) {
    Console.WriteLine ("goedzo, er zijn " + nummervanappels + " appels");
}
while (nummervanappels > 15) { 
    Console.WriteLine ("dat zijn er te veel");
    System.Threading.Thread.Sleep(2000);
    Console.WriteLine ("raad opnieuw");
    System.Threading.Thread.Sleep(2000);
    nummervanappels = Convert.ToInt32 (Console.ReadLine ());


}
while (nummervanappels < 15) {
    Console.WriteLine ("dat zijn er te weinig");
    System.Threading.Thread.Sleep (2000);
    Console.WriteLine ("raad opnieuw");
    System.Threading.Thread.Sleep (2000);
    nummervanappels = Convert.ToInt32 (Console.ReadLine ());
}

Console.ReadKey ();

我希望你们能帮助我。

2 个答案:

答案 0 :(得分:1)

我相信这就是你想要的。

<!DOCTYPE html>
<html>
   <head>
      <meta charset="UTF-8">
      <title>Substring Test</title>
      <script type="text/javascript"> 

         function displayContent() {
         var contentEntered = document.getElementById("userContent").value; 
         var contentEnteredSecond = document.getElementById("secondUserContent").value;
               document.getElementById("result").innerHTML += "<p> The content entered was " + contentEntered + " </p>"; 
               document.getElementById("result").innerHTML += "<p> The content entered was " + contentEnteredSecond + " </p>"; 
         }

      </script>
   </head>
   <body>
      <h1>Substring</h1>
      <div id="mainCont">
         <p>Please enter any content.</p>
         <p>Content:
            <input type="text" id="userContent">
         </p>
         <p>Content:
            <input type="text" id="secondUserContent">
         </p>
         <p>
            <input type="button" onclick="displayContent();" value="Submit">
         </p>
         <div id="result"></div>
      </div>
   </body>
</html>

一个Console.Write ("hoeveel appels zijn er :"); int nummervanappels = Convert.ToInt32(Console.ReadLine()); while (nummervanappels != 15) { if(nummervanappels > 15) Console.WriteLine("dat zijn er te veel"); else Console.WriteLine("dat zijn er te weinig"); System.Threading.Thread.Sleep(2000); Console.WriteLine ("raad opnieuw"); System.Threading.Thread.Sleep(2000); nummervanappels = Convert.ToInt32(Console.ReadLine()); } Console.WriteLine ("goedzo, er zijn " + nummervanappels + " appels"); Console.ReadKey (); 循环,直到用户输入15 while来告诉他们是否太高或太低。然后是关于最后正确数字的陈述。我不知道你为什么要睡2秒,但我把它们留在那里。

您也可以将if - if更改为

else

答案 1 :(得分:0)

看起来你想要这个

void write_lines(char** array_of_string)
{
    // char * = string (pointer to string start)
    // char ** = array of strings
    // the pointer to string start should be valid
    for(; *array_of_string; array_of_string++)
        printf("%s", *array_of_string);
}