string[,] scare = new string[,] { { "吳淞", "89" }, { "錢東宇", "90" }, { "伏晨", "98" },{ "鄭帥", "88" } };
int max = 0;
string name = "";
for (int i = 0; i < scare.GetLength(0);i++)
{
if (int.Parse(scare[i,1])>max)
{
int max = 0;
string name = "";
for (int i = 0; i < scare.GetLength(0);i++)
{
if (int.Parse(scare[i,1])>max)
{
string[] name={"景珍","林惠洋","成蓉","洪南昌","龍玉民","單江開","田武山","王三明"};//聲明數據name
int[] score={90,65,88,70,46,81,100,68};//聲明數組score
int sum=0;//存放分數之和
int avg;//存放平均分(總分/數組長度)
for(int i=0;i<score.Length;i++)
{
sum=sum+score[i];
}
int[] score={90,65,88,70,46,81,100,68};//聲明數組score
int sum=0;//存放分數之和
int avg;//存放平均分(總分/數組長度)
for(int i=0;i<score.Length;i++)
{
sum=sum+score[i];
}
x++;
Console.Write(x);
Console.Write(y+1);
Console.Write(++z);
Console.Write(x);
Console.Write(y+1);
Console.Write(++z);
2018-09-28
foreach(int x in num)
{
if(x%7==0)
{
Console.Write("有7的整倍數");
}
else
{
Console.Write("沒有7的整倍數");
break;
}
}
這樣寫的是錯的,因為這樣如果數組元素中有1個以上的能被7整除的元素,那么就會打印多次(有7的整數倍)這段話,而我們并不想看到這樣.
{
if(x%7==0)
{
Console.Write("有7的整倍數");
}
else
{
Console.Write("沒有7的整倍數");
break;
}
}
這樣寫的是錯的,因為這樣如果數組元素中有1個以上的能被7整除的元素,那么就會打印多次(有7的整數倍)這段話,而我們并不想看到這樣.
int y = 5;
while (y<=5&&y>0)//請輸入
{
Console.Write(y+" ");
//請輸入
y--;
}
while (y<=5&&y>0)//請輸入
{
Console.Write(y+" ");
//請輸入
y--;
}
2018-09-24