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

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

My problem:Crash (access violation) test6
Послано siyuan503 16 авг 2007 19:21
  Although I tried so many times,it showed Crash (access violation) test6.
  Who can tell me why,thanks.
  My mainly code:

main ()
{
 int n=0,i;
 double a, b[100];
 for(i=0;i<100;i++)
  b[i]=0;
 while(scanf("%lf",&a)!=EOF)
 {  b[n]=sqrt(a);  n++;}
 for(i=n-1;i>=0;i--)
  printf("%.4lf\n",b[i]);
}
Re: My problem:Crash (access violation) test6
Послано CHIDEMYAN SERGEY 16 авг 2007 19:45
Array of 100 elements doesn't enough.Create a dynamic array of 8000000 elements.Just do
double *b=new double[8000000];
Good luck!

Edited by author 16.08.2007 19:46

Edited by author 16.08.2007 19:47

Edited by author 16.08.2007 19:47

Edited by author 16.08.2007 19:50
Re: My problem:Crash (access violation) test6
Послано siyuan503 16 авг 2007 20:11
Sorry,my problem is "double *b=new double[8000000];"seems not available in C!
Re: My problem:Crash (access violation) test6
Послано siyuan503 16 авг 2007 20:16
if i write double[8000000]in C,it say overflow!
i will mad!
if this problem can't be achieved by C!
Re: My problem:Crash (access violation) test6
Послано CHIDEMYAN SERGEY 17 авг 2007 18:33
Ok.I'm don't well on C enough.Just do:
#include<stdio.h>
main ()
{
int n=0,i;
double a;
double *b=new double[8000000];
while(scanf("%lf",&a)!=EOF)
{ b[n]=sqrt(a); n++;}
for(i=n-1;i>=0;i--)
printf("%.4lf\n",b[i]);
return 0;
}
and you'll get AC on C++.

Edited by author 17.08.2007 18:33
Re: My problem:Crash (access violation) test6
Послано siyuan503 24 авг 2007 20:38
Thank you very much!
I will try it again.