|
|
back to boardC# Can you please tell me why ? HELP ! my english is poor so this is the program using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Collections; namespace ACM1001test { class Program { static void Main(string[] args) { string[] arr = (Console.ReadLine()).Split(' '); Stack sck = new Stack(); for (int i = 0; i < arr.Length;i++ ) { sck.Push(arr[i]); } foreach (string str in sck) { int a=Convert.ToInt32(sck.Pop()); Console.WriteLine("{0}/n",Math.Round(Math.Sqrt(a), 4)); } } } } Re: C# Can you please tell me why ? HELP ! Posted by Alksar 1 Feb 2013 03:14 1. string[] arr = (Console.ReadLine()).Split(' '); Number of lines may be more then one, use cycle 2. the number of spaces between the numbers of more than one, use Console.ReadLine().Split(new char[] {' ', '\t'}, StringSplitOptions.RemoveEmptyEntries) 3. Int32<10^18; Re: C# Can you please tell me why ? HELP ! thanks Alksar so i made some changes but some problems is still here .this is the new program class Program { static void Main(string[] args) { string[] arr = Console.ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries); Stack sck = new Stack(); for (int i = 0; i < arr.Length;i++ ) { sck.Push(arr[i]); } foreach (string str in sck) { ulong a=Convert.ToUInt64(sck.Pop()); Console.WriteLine("{0}/n",Math.Round(Math.Sqrt(a), 4)); } } } when i input the "16 4" the computer output the "20" so awkwardful..... Re: C# Can you please tell me why ? HELP ! Posted by Alksar 1 Feb 2013 13:18 I have changed your program just a little, it works nice namespace ACM1001test { class Program { static void Main(string[] args) { string[] arr = Console.ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries); Stack sck = new Stack(); for (int i = 0; i < arr.Length; i++) { sck.Push(arr[i]); } while (sck.Count>0) { ulong a = Convert.ToUInt64(sck.Pop()); Console.WriteLine(Math.Round(Math.Sqrt(a), 4)); } Console.ReadKey(); } } } Re: C# Can you please tell me why ? HELP ! thanks but when i input "16 4"the computer also output "20" when i submit the program i get the Crash and i used the others Program which use C# have got the AC,they also output "20". it is not should put out"2 4"? or i am not understand the meaning... |
|
|