我提交的ACM题库的答案
最近园子里流行做俄罗斯乌拉尔大学在线题库我也就做了一下,下面是1000题和1001题的代码:
Problem 1000:
Problem 1000:
1
int main()
2
{
3
int a, b;
4
clrscr();
5
scanf("%d %d", &a, &b);
6
printf("%d", a+b);
7
}
Problem 1001:
int main()2
{3
int a, b;4
clrscr();5
scanf("%d %d", &a, &b);6
printf("%d", a+b);7
} 1
using System;
2
using System.Threading;
3
using System.Globalization;
4
5
namespace ConsoleApplication4
6
{
7
class Program
8
{
9
static void Main(string[] args)
10
{
11
// 注意下面一行代码,如果少了的话,你永远也通过不了,哈哈
12
Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
13
string[] inputArray = Console.In.ReadToEnd().Split();
14
for (int i = inputArray.Length - 1; i >= 0; i--)
15
{
16
if (!String.IsNullOrEmpty(inputArray[i]))
17
{
18
Console.WriteLine("{0:F4}", Math.Sqrt(Convert.ToDouble(inputArray[i])));
19
}
20
}
21
}
22
}
23
}
原因是什么,在这里有人解释了,注意看回复的第二楼。
using System;2
using System.Threading;3
using System.Globalization;4

5
namespace ConsoleApplication46
{7
class Program8
{9
static void Main(string[] args)10
{11
// 注意下面一行代码,如果少了的话,你永远也通过不了,哈哈12
Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;13
string[] inputArray = Console.In.ReadToEnd().Split();14
for (int i = inputArray.Length - 1; i >= 0; i--)15
{16
if (!String.IsNullOrEmpty(inputArray[i]))17
{18
Console.WriteLine("{0:F4}", Math.Sqrt(Convert.ToDouble(inputArray[i])));19
}20
}21
}22
}23
}


浙公网安备 33010602011771号