|
|
вернуться в форумПодводные камни "1001.Обратного корня" Послано Yegor 14 июл 2015 17:08 //if 'double s[130196]' before 'int main()' - all is OK!! //but if 'double s[130196]' in 'int main()' then Runtime error (stack overflow)!!!!!!! //------------------------------------------------- //AND MAGIC №2: //any number after 130196 (for example 130196,130197...) in 'double s[130196]' - all is OK!! //BUT numbers before 130196, for example 130195, 130194... then Runtime error (access violation)!!! //------------ //on the internet people use 'double s[131072]' - it is 2^17, why???? if i can use 130196 //------------------ #include <iostream> #include <iomanip> #include <cmath> using namespace std; double s[130196];// if 130195 or < then Runtime error (access violation)!!! int main() { //double s[130196]; - if in 'int main()' then Runtime error (stack overflow) int t = 0; while (cin>>s[t]){t++;} while(t>0){cout<<fixed<<setprecision(4)<<sqrt((double)s[--t])<<endl;} return 0; } //why why why ??)) Edited by author 14.07.2015 17:12 Re: Подводные камни "1001.Обратного корня" Послано ballon 15 июл 2015 02:35 Array from main function is kept in stack memory, and this memory is limited. You should declare it as global, or increase stack size. |
|
|