C:\pyramid.exe 7
would generate a pyramid like this:
I know that there is some script like Python, Ruby and so on can make a single line of code to generate this pyramid. But the condition is not to use a special function or library. I just solved this puzzle within 3 hours with Visual C++ 6.0. Here it is a single long line of code:
void main(int r,char * g[]){for(int i=((atoi(g[1])+1)/2);i>0;i--){for(int j=i-1;j>0;j--)cout<<" ";for(int k=1; k<=(((atoi(g[1])+1)/2)-i+1);k++)cout<<"*";for(k=(((atoi(g[1])+1)/2)-i+1)-1;k>0;k--)cout<<"*";for(j=i-1;j>0;j--)cout<<" ";cout<<"\n";}}
Thus, this code still need to insert a header file <iostream.h> and <stdlib.h> for print the result and the atoi function for converting ASCII to Integer from the given argument. But this is standard for C programming. All scripting language for sure need all these stuff for the script that communicate with core engine. Coding with C++ might be various depend on your platform and compiler.
Enjoy...
hahah... sorang lagi dah siap..
ReplyDeleteaik.. ada game ke abg xanda? teringat sem1 dlu.. buat menda nilah... pastu buat yang segi tiga terbalik plak.. XD
ReplyDeletesaudara alternator, kongsilah skit ilmu kaji malware..XD
hehehe, aku dulu buat pakai c++ nih, piramid terbalik semua ada..
ReplyDelete