在内层加一行else;就OK,目的是使原本的else与上面那个匹配,那么只要弄个else;与第二个匹配就行,;是因为不需要执行块
if (x >= y)
if (x >= 5)
Console.WriteLine("5");
else;
else
if (y >= 6)
Console.WriteLine("6");
else
Console.WriteLine("7");
if (x >= y)
if (x >= 5)
Console.WriteLine("5");
else;
else
if (y >= 6)
Console.WriteLine("6");
else
Console.WriteLine("7");
2017-01-30
int[] num = {89,90,98,56,60,91,93,85};
string[] y = { "吴松","钱东宇","伏晨","陈路","周蕊","林日鹏","何昆","关欣" }
int max = num[0];
int index = 0;
for(int i = 0; i < num.GetLength(0); i++)
if(max < num[i])
max = num[i];
index = i;
int dex = 0;
for (int q = 0; q < y.GetLength(0); q++)
dex = q;
if (index == dex)
自己排下
string[] y = { "吴松","钱东宇","伏晨","陈路","周蕊","林日鹏","何昆","关欣" }
int max = num[0];
int index = 0;
for(int i = 0; i < num.GetLength(0); i++)
if(max < num[i])
max = num[i];
index = i;
int dex = 0;
for (int q = 0; q < y.GetLength(0); q++)
dex = q;
if (index == dex)
自己排下
bool t = false;
foreach (int a in num)//请完善代码,判断数组中有没有7的整倍数
{
if (a % 7 == 0)
{
t = true;
break;
}
}
String u = t ? "a" : "没有7的整倍数";
Console.WriteLine(u);
foreach (int a in num)//请完善代码,判断数组中有没有7的整倍数
{
if (a % 7 == 0)
{
t = true;
break;
}
}
String u = t ? "a" : "没有7的整倍数";
Console.WriteLine(u);