My discussion

old (HH)
本文发表在 rolia.net/zh 相约加拿大网上社区枫下论坛
Thank you for your discussion!

1. You answer of 0.02-0.08 seconds is not reasonable. You answer means that under that condition any program can not last to run for more than 0.02-0.08 seconds.
2. My understanding of upper bound here is as long as possible.
3. Of course as you said we can also assume i is a huge digital which occupies all of the 1 MB memory except several bytes used by the instructions for iterative operation. But in such case we will waist a lot of memory to do iteration operations. The more the iteration operations (for(){for(){for(){...}}}) we put in a program the more time it can last to run.

// The range of subscripts for vals[] should be 0 to 199 if this is a C program.
// vals[200] is out of the memory block you allocated. Dangerous!
// Please change vals[200] to vals[199], then run it and tell me the result.
// Let's learn from our mistakes! Thank you again!
int *vals,*ptr;
vals = malloc(sizeof(int)*200);
memset (vals,'\0',sizeof(int)*200);
while(!vals[200]) // error: vals[200] is out of the block of you allocated
*(ptr = vals) += 1;
while (*ptr == 10)
*ptr++ = 0;
*ptr += 1;
更多精彩文章及讨论,请光临枫下论坛. 网址: rolia.net/zh
2001-2-11 -04:00
This post has been archived. It cannot be replied.
Page address has been copied. To share, click to copy page address.
Share Online by QR Code

Back To Topic: An interesting question.

Back To Forum: HOME枫下论坛枫下论坛主坛工作学习IT技术讨论