对于具有用户输入的循环

时间:2015-11-14 22:46:27

标签: c# .net string loops for-loop

我试图弄清楚如何用C#编写代码。

用for循环编写一个c#程序,它将执行以下输出:

What would  you like to say?
 HELLO
How many times  would you like this phrase to be repeated?
4
HELLO
HELLO
HELLO
HELLO

我对于该怎么做感到困惑,这是我到目前为止所做的事情;

string word;
int number;
string total;

Console.WriteLine("What would you like to say?");
word = Convert.ToString(Console.ReadLine());

Console.WriteLine("How many times would you like it repeated?");
number = Convert.ToInt32(Console.ReadLine());

total = word + number;

for (string word = total; );

0 个答案:

没有答案