using System;
class Test
{
public static void Main()
{
int y=0;
int x=Convert.ToInt32(Console.ReadLine());
if(x>0)
{
y=1;
}
else
(
if(x==0)
{
y=0;
}
else
{
y=-1;
}
)
Console.WriteLine(y);
}
}
你确信这种地方用小括号可以?
class Test
{
public static void Main()
{
int y=0;
int x=Convert.ToInt32(Console.ReadLine());
if(x>0)
{
y=1;
}
else
(
if(x==0)
{
y=0;
}
else
{
y=-1;
}
)
Console.WriteLine(y);
}
}
你确信这种地方用小括号可以?
解决方案 »
- winform中嵌入word问题
- 寻求思路“论坛自动回帖”
- C#有没有办法获取DLL里面的函数名?DllImport出了点问题
- datagrid数据更新问题
- c#做了一个数据库小程序用于货物清单打印输出,在我的机器上能用,移植到其他的机器就出现了问题,错误代码如下
- .net
- 比较郁闷! 讨论个问题顺便发发分 快过年了!
- textBox1_KeyDown事件里,我只想接受0~9的数字和回车事件
- 各位大哥,小妹求助C#打印锯齿问题。
- 问一个有关c#正则表达式的问题
- 求救..如果使用SQL语句把数据插进ReportView
- 請問怎麼才能將GRIDVIEW中的數據導到EXCEL並由用戶選擇路徑存入客戶端,並在字符型或所有字段值前加入單引號?
( ==>{
if(x==0)
{
y=0;
}
else
{
y=-1;
}
) ==> }
using System;
class Test
{
public static void Main()
{
int y=0;
int x=Convert.ToInt32(Console.ReadLine());
if(x>0)
{
y=1;
}
else if(x==0)
{
y=0;
}
else
{
y=-1;
}
Console.WriteLine(y);
}
}
int x=Convert.ToInt32(Console.ReadLine());
if(x>0)
{
y=1;
}
else
( if(x==0)
{
y=0;
}
else
{
y=-1;
}
) Console.WriteLine(y); 是{} 不是()
{
//doing……
}
else
{
//doing
}if(表达式)
{
//doing……
}
else if(表达式)
{
//doing
}
不过使用 Convert.ToInt32()
确保括号内的是数字而不是字符
{
public static void Main()
{
int iX = 0;
int iY = 0;
bool bInt = false; while (!bInt)
{
bInt = int.TryParse(Console.ReadLine(), out iX);
} if (iX > 0)//流程分支把最可能出现的情况写在最前面
{
iY = 1;
}
else if (iX < 0)
{
iY = -1;
}
else
{
iY = 0;
} Console.WriteLine(iY);
Console.Read();
}
}
class Test
{
public static void Main()
{
int y=0;
int x=Convert.ToInt32(Console.ReadLine()); if(x>0)
{
y=1;
}
else
{
if(x==0)
{
y=0;
}
else
{
y=-1;
}
}
Console.WriteLine(y);
}
}