XiaoMing is newbie of C programming, recently he wrote a c program to print 99 '#' sign, as the following :
[code] int i,n=99;main(){for(i=0;i [/code]
but apparently this is wrong
Question 1 : please help him to correct this program, but only one of these kinds of modifications are allowed : 1. delete one character 2. insert one character 3. change one character
Question 2 : The same restriction ditto, but to output only one '#'
Question 3 : ditto, but to output 100 '#'
correndo!
Miao,
----------------------------
Subject:
Re: deixe-nos jogar o jogo de C programming!
Date:
Thu, 03 Apr 2008 14:48:02 +0100
Mailer:
Evolution 2.12.3 (2.12.3-3.fc8)
Hi all,
Let's reveal the ultimate answer,
$ time perl 2.pl 099# : int i,n=99;main(){for(i=0;i 001# : int i,n=99;main(){for(i=0;i<&n;i--){printf("#");}} 001# : int* i,n=99;main(){for(i=0;i 001# : int *i,n=99;main(){for(i=0;i 001# : int i,*n=99;main(){for(i=0;i 001# : int*i,n=99;main(){for(i=0;i 099# : int i,n=99;main(){for(i=0;i+n;i--){printf("#");}} 099# : int i,n=99;main(){for(i=0;-i 001# : int i,n=99;main(){for(i=0;i 100# : int i,n=99;main(){for(i=0;~i
real 4m9.062s user 2m45.403s sys 1m11.831s
099# means the code outputs 99 '#' 001# means the code outputs 1 '#' 100# means the code outputs 100 '#'
The solution here is somehow stupid, we test every possible modified codes(around 9000 possibilities) and send it to gcc for compiling, and if it's compilable then we check the output of compiled program. But we got some intelligent answers and the whole process took only 4 minutes on my laptop :
001# : int i,n=99;main(){for(i=0;i<&n;i--){printf("#");}} 001# : int *i,n=99;main(){for(i=0;i
--
Will we be replaced by HAL from '2001 : A Space Odyssey'?