My question is to coding for a text editor where the operations * 1-append 2-delete k characters from last 3-print nth character 4-undo * Input format is * The first line contains an integer,Q, denoting the number of operations. Each line i of the Q subsequent lines (where 0&lt;=i&lt;=Q) defines an operation to be performed. Each operation starts with a single integer, t (where t is either 1 or 2 or 3 or 4), denoting a type of operation as defined in the Problem Statement above. If the operation requires an argument, t is followed by its space-separated argument. For example, if t=1 and W=&quot;abcd&quot; , line i will be 1 abcd. * This is my code #include &lt;stdio.h&gt; #include &lt;string.h&gt; #include &lt;math.h&gt; #include &lt;stdlib.h&gt; #define max 10000  char stack[max],super[max][max]; int top=-1,btop=-1,supert=-1; int bottom=1,qqq=0;  void push(char elem[]) {     //top++;     btop=top;     int i=0;     strcat(stack,elem);     strcpy(super[++supert],stack); }  void pop(int k) {     top=strlen(stack);     for(int i=0;i&lt;k;i++)     {         top--;     }     stack[top]='\0';     /*int i=0;     if(top==-1)     {         strcpy(stack,&quot;&quot;);     }     else     {         i=top;         while(i&lt;btop)         {             i++;             stack[i]='\0';         }     }*/     strcpy(super[++supert],stack); }  int main()  {     int tot,op;     scanf(&quot;%d&quot;,&amp;tot);     int q=0;     for(int i=0;i&lt;tot;i++)     {         scanf(&quot;%d&quot;,&amp;op);         switch(op)         {             case 1:;                 char elem[max];                 scanf(&quot;%s&quot;,elem);                 push(elem);                 //printf(&quot;%s\n&quot;,stack);             break;                          case 2:;                 int num;                 scanf(&quot;%d&quot;,&amp;num);                 pop(num);                 //printf(&quot;%s\n&quot;,stack);             break;                          case 3:;                 int k;                 qqq++;                 scanf(&quot;%d&quot;,&amp;k);                 /*if(qqq%2==0)                 {                     printf(&quot;%c\n&quot;,stack[k-3]);                 }                 else                 {                     printf(&quot;%c\n&quot;,stack[k-1]);                 }*/                 printf(&quot;%c\n&quot;,stack[k-1]);                              break;                          case 4:;                 supert=supert-1;                 strcpy(stack,super[supert]);                 q--;                 //printf(&quot;%s\n&quot;,stack);             break;         }         q++;     }        return 0; }  For extremely large inputs(operations in the order of 10^5 or 10^6) I am getting segmentation fault Also I could not increase the size of max because if I increase I am getting an error Why is it so?
The following code is generating a stack overflow error for me  int main(int argc, char* argv[]) {     int sieve[2000000];     return 0; }   How do I get around this? I am using Turbo C++ but would like to keep my code in C  EDIT:  Thanks for the advice.  The code above was only for example, I actually declare the array in a function and not in sub main.  Also, I needed the array to be initialized to zeros, so when I googled malloc, I discovered that calloc was perfect for my purposes.  Malloc/calloc also has the advantage over allocating on the stack of allowing me to declare the size using a variable.
Why $e^x$ is always greater than $x^e$? I find it very strange that $$ e^x \geq x^e \, \quad \forall x \in \mathbb{R}^+.$$   I have scratched my head for a long time, but could not find any logical reason. Can anybody explain what is the reason behind the above inequality? I know this is math community, but I'd appreciate a more intuitive explanation than a technical one. How to look up a symbol or identify a letter from a math alphabet or other character? I have a number of tiff files named:    sw.001.tif sw.002.tif ...   and I want to remove the .tif at the end of each of the files.  How can I use the rename command to do this? jQuery/JavaScript to replace broken images The characteristic and minimal polynomial of a companion matrix How do I increase the render distance? I have created a simple model here   When rendering it the end of it is cut off   How can I get the camera to render a longer distance? How to replace all occurrences of a string in JavaScript? According to the documentation, the  method uses a round-to-even algorithm which is not common for most applications. So I always end up writing a custom function to do the more natural round-half-up algorithm:  public static decimal RoundHalfUp(this decimal d, int decimals) {     if (decimals &lt; 0)     {         throw new ArgumentException("The decimals must be non-negative",              "decimals");     }      decimal multiplier = (decimal)Math.Pow(10, decimals);     decimal number = d * multiplier;      if (decimal.Truncate(number) &lt; number)     {         number += 0.5m;     }     return decimal.Round(number) / multiplier; }   Does anybody know the reason behind this framework design decision?  Is there any built-in implementation of the round-half-up algorithm into the framework? Or maybe some unmanaged Windows API?  It could be misleading for beginners that simply write decimal.Round(2.5m, 0) expecting 3 as a result but getting 2 instead. Should confidence intervals for linear regression coefficients be based on the normal or $t$ distribution? I've used recursion quite a lot on my many years of programming to solve simple problems, but I'm fully aware that sometimes you need iteration due to memory/speed problems.  So, sometime in the very far past I went to try and find if there existed any "pattern" or text-book way of transforming a common recursion approach to iteration and found nothing. Or at least nothing that I can remember it would help.   Are there general rules? Is there a "pattern"? Can I use I2C over 2m cables? Proving that $\lim_{n \rightarrow\infty} \int_{0}^{\frac{\pi}{2}} \sin(t^n) dt =0$ It is clear that $\lim_{n \rightarrow\infty} \int_{0}^{1} \sin(t^n) dt =0$. (which is not what is to be proved here)  I don't know how to proceed with the remaining part of the integral ie $\lim_{n \rightarrow\infty} \int_{1}^{\frac{\pi}{2}} \sin(t^n) dt$ (I tried substitution and partial integration).  Can anybody give me a hint ? When using data.stackexchange.com I fail to remember if as [post link] is the correct alias to get the url for the post. Luckily the site has an  link. Unfortunately it is now broken. Can this be fixed? What is the correct way to show tiered possession? When there are multiple places where possession is shown, how are the words structured?  A few examples:   Greg's son's laptop is on fire. Mary's friends' boat is sinking. Thomas's neighbor's cat ate a mouse. Apple's Stock App's stats are useful. Microsoft's Xbox 360's games are fun.   Are these the correct ways to express possession? How do you generate dynamic (parameterized) unit tests in Python? Is a 2-hour transit time enough to catch a connecting flight in Muscat airport? Both flights are with Oman Air I am flying from Dubai to India with Oman Air with a layover of 2 hours at Muscat airport. Is 2 hours enough for me to catch my connecting flight from Muscat to New Delhi? My flight from Dubai to Muscat as well as the connecting flight from Muscat to New Delhi are with Oman Air. Do I need to re-check in my luggage? Am I taking a risk or should I take an earlier flight from Dubai to get more layover time to be on the safer side? Footnote to an item in a description environment It seems like it's not possible to put footnote inside a description list item.  For example in the following code first footnote appears at the bottom of the page, but the second - doesn't:  \documentclass[a4paper,12pt]{article}  \begin{document}     Text text text.\footnote{This footnote is working}     \begin{description}         \item[Label\footnote{This footnote is not working}] Some description     \end{description} \end{document}   Why it's not working this way? And is there any way to put footnote to a list item? Can't paste data to question, get prompted for Image? An irreducible polynomial of degree coprime to the degree of an extension is irreducible over this extension I'm having a hard time showing this:     If $K$ is an extension of $\mathbb{Q}$ with degree $m$ and $f(x)$ an irreducible polynomial over the rationals with degree $n$, such that $\gcd(m, n)=1$, then $f(x)$ is irreducible over $K$.   I have tried it by writing $f(x)=a(x)b(x)$ and then looking at the coefficients of those polynomials (some of them must belong to $K-\mathbb{Q}$ which could possibly result in a contradiction) to no success. I have no idea where to use the hypothesis of m and n being relatively prime.  Any help would be appreciated. How resilient is Ubuntu to repeated "power-off" shutdowns? My company is considering the use of Ubuntu as an OS for use on a hardware device.     It would be installed on compact flash drive - apparently this is not standard flash drive but a specific type of memory that is supposed to "cope" with immediate power shutdown (I am not sure how this is achieved but they are supposedly a "high end" card).    The units that would be run using Ubuntu are the type of units that will not be gracefully shutdown - the power cable would be removed and that is that.     Can anybody give me some advice on the potential problems that can occur? Is Ubuntu a good system that can deal with this kind of power outage and reboot successfully on next startup?     I realise that nothing is unbreakable, but is it a commonly used OS for an embedded setup? Is it asking for trouble to use Ubuntu in this kind of environment?