ENG  RUSTimus Online Judge
Online Judge
Задачи
Авторы
Соревнования
О системе
Часто задаваемые вопросы
Новости сайта
Форум
Ссылки
Архив задач
Отправить на проверку
Состояние проверки
Руководство
Регистрация
Исправить данные
Рейтинг авторов
Текущее соревнование
Расписание
Прошедшие соревнования
Правила
вернуться в форум

Обсуждение задачи 1001. Обратный корень

C# Can you please tell me why ? HELP !
Послано lanjiashu 31 янв 2013 20:00
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 !
Послано Alksar 1 фев 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 !
Послано lanjiashu 1 фев 2013 06:48
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 !
Послано Alksar 1 фев 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 !
Послано lanjiashu 1 фев 2013 14:01
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...