Soooo这个程序似乎是合乎逻辑的,而且我已经能够在c ++和java中创建具有相同想法的程序,每当我运行它时,一切都会突然关闭......也许我只是下载了错误的东西
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication3
{
class Program
{
static void Main(string[] args)
{
/*
int[] numbahs= new int[5];
numbahs[0] = 4;
numbahs[1] = 3;
Console.WriteLine(numbahs[1].ToString());
string[] cow = new string[] { "pee", "poop" };
foreach (string pee in cow)
{
Console.WriteLine(pee);
}
*/
int x;
int y;
Console.WriteLine("enter x:");
x = Console.Read();
Console.WriteLine("enter y:");
y = Console.Read();
int z = (x > y)? 8 : 2;
Console.WriteLine("x:{0} y:{1} z:{2}",x ,y, z);
if (z > x)
{
Console.WriteLine("yoyo");
Console.Read();
}
else { Console.WriteLine("hihi"); }
Console.Read();
}
}
}
Run Code Online (Sandbox Code Playgroud)
使用Console.ReadLine
int x;
int y;
Console.WriteLine("enter x:");
x = int.Parse(Console.ReadLine());
Console.WriteLine("enter y:");
y = int.Parse(Console.ReadLine());
int z = (x > y)? 8 : 2;
Console.WriteLine("x:{0} y:{1} z:{2}",x ,y, z);
if (z > x)
{
Console.WriteLine("yoyo");
}
else { Console.WriteLine("hihi"); }
Console.ReadLine();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
101 次 |
| 最近记录: |