string[] a = { "景珍", "林惠洋", "成蓉", "洪南昌", "龍玉民", "單江開", "田武山", "王三明" };
int[] b = { 90,65,88,70,46,81,100,68 };
avg = sum / a.Length;
Console.WriteLine("平均分是{0},高于平均分的有:",avg);
for (int j = 0; j < b.Length; j++)
{
if (b[j] > avg)
{
Console.Write(a[j] + " ");
}
}
int[] b = { 90,65,88,70,46,81,100,68 };
avg = sum / a.Length;
Console.WriteLine("平均分是{0},高于平均分的有:",avg);
for (int j = 0; j < b.Length; j++)
{
if (b[j] > avg)
{
Console.Write(a[j] + " ");
}
}
char[,] ch = { {'我','是','軟'},{'件','工','程'},{'師','啦','!'}};
Console.WriteLine("{0}{1}{2}",ch[1,1],ch[1,2],ch[2,0]);
Console.WriteLine("{0}{1}{2}",ch[1,1],ch[1,2],ch[2,0]);
2015-09-10
//請完善代碼,判斷數(shù)組中有沒有7的整倍數(shù)
bool a = false;
for (int i = 0; i < num.Length; i++)
{
if (num[i] % 7 == 0)
a = true;
}
if (a)
Console.WriteLine("有7的整倍數(shù)");
else
Console.WriteLine("沒有7的整倍數(shù)");
bool a = false;
for (int i = 0; i < num.Length; i++)
{
if (num[i] % 7 == 0)
a = true;
}
if (a)
Console.WriteLine("有7的整倍數(shù)");
else
Console.WriteLine("沒有7的整倍數(shù)");
2015-09-10
string[] t = new string[] { "C", "Sh", "a", "rp" };
foreach (string x in t)//遍歷字符串?dāng)?shù)組t
{
Console.Write(x);
}
foreach (string x in t)//遍歷字符串?dāng)?shù)組t
{
Console.Write(x);
}
2015-09-10
//聲明整型數(shù)組,保存一組整數(shù)
int[] num = new int[] { 3, 34, 42, 2, 11, 19, 30, 55, 20 };
//請完善代碼,循環(huán)打印數(shù)組中的偶數(shù)
for (int i = 0; i < num.Length; i++)
{
if (num[i] % 2 == 0)
{ Console.Write(num[i] + ","); }
}
int[] num = new int[] { 3, 34, 42, 2, 11, 19, 30, 55, 20 };
//請完善代碼,循環(huán)打印數(shù)組中的偶數(shù)
for (int i = 0; i < num.Length; i++)
{
if (num[i] % 2 == 0)
{ Console.Write(num[i] + ","); }
}
2015-09-10
int[] score = new int[] { 89, 39, 100, 51, 94, 65, 70 };//分?jǐn)?shù)
Console.Write("不及格的有:");
for (int i = 0; i < score.Length; i++)
{
if ( score[i]<60 )//篩選條件
Console.Write(score[i] + ",");
}
Console.Write("不及格的有:");
for (int i = 0; i < score.Length; i++)
{
if ( score[i]<60 )//篩選條件
Console.Write(score[i] + ",");
}
2015-09-10