Đề bài này kiểm tra kĩ thuật lập trình đơn giản. Mình demo đoạn code bằng C# cho bạn hiểu ý tưởng làm, bạn tự chuyển qua C++ nhé
Code:
class Program
{
static void Main(string[] args)
{
// read input string
Console.Write("Nhap day so (cach nhau bang dau ,): ");
String arrayNum = Console.ReadLine();
// split input string
String[] num = arrayNum.Split(new char[] { ','}, StringSplitOptions.RemoveEmptyEntries);
for(int i = 0; i < num.Length-1; ++i)
{
for(int j = 0; j < num.Length; ++j)
{
Int32 a = Convert.ToInt32(num[i]);
Int32 b = Convert.ToInt32(num[j]);
// check if (a^2 + b^2) is an even number
if((a * a + b * b) % 2 == 0)
{
Console.WriteLine("{0} - {1}", a, b);
}
}
}
}
}
P/s: theo như đề bài thì (a,b) # (b,a)