int[] score;
int x = 0;
int sum;
score = new int[4];
for (int n = 0; n < score.Length; n++)
{
Console.Write("Enter n[" + n + "] :");
x = int.Parse(Console.ReadLine());
}
sum = x % 10;
Console.WriteLine();
Console.Write("Output...\n");
Console.WriteLine();
Console.Write("is {0}\n", sum);
int[] score;
int x = 0;
int sum;
score = new int[4];
for (int n = 0; n < score.Length; n++)
{
Console.Write("Enter n[" + n + "] :");
x = int.Parse(Console.ReadLine());
sum = x % 10;
Console.WriteLine();
Console.Write("Output...\n");
Console.WriteLine();
Console.Write("Last digit of n is {0}\n", sum);
}
int[] score;
int x = 0;
string sum;
score = new int[4];
for (int n = 0; n < score.Length; n++)
{
Console.Write("Enter n[" + n + "] :");
x = int.Parse(Console.ReadLine());
sum += " " + x +"%"+ 10 +":" + x % 10 ;
}
Console.WriteLine();
Console.Write("Output...\n");
Console.WriteLine();
Console.Write("Last digit of n is {0}\n", sum);
ใช่แบบนี้ป่าวครับ
Date :
2015-12-08 16:21:32
By :
lamaka.tor
No. 4
Guest
Code (C#)
int[] score;
int x = 0;
int[] sum;
score = new int[4];
sum = new int[4];
for (int n = 0; n < score.Length; n++)
{
Console.Write("Enter n[" + n + "] :");
x = int.Parse(Console.ReadLine());
sum[n] = x % 10;
}
Console.WriteLine();
Console.Write("Output...\n");
Console.WriteLine();
string show = "";
for (int n = 0; n < score.Length; n++)
{
show += sum[n] + " ";
}
Console.Write("Last digit of n is {0}\n", show);
Console.Read();