聚星亭

吾笨笨且懒散兮 急须改之而奋进
posts - 74, comments - 166, trackbacks - 0, articles - 0
  C++博客 :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理
比赛的地址是:http://www.ghoffice.com/bbs/read-htm-fid-97-tid-63475.html

引用一下原题目:

      引用的内容    
编程乐园的人气貌似不强,难道大家无会编程的?

希望各大高手,新手通通出马.尽现你的才华哦.


PS:该帖来自编程乐园的转向,所有权在编程乐园,应当采用编程乐园的规则,希望大家不要放水


比赛内容:【打印99乘法口诀】(简单吧)

要求:用最短的,最奇怪,或着是最有特色代码,语言不限,禁抄袭

评奖:到50帖时

奖励设置:

一等奖 (1名)100论坛币    50威望

二等奖(2名)80论坛币  30威望

三等奖(3名)50论坛币   20威望

优秀奖(若干)10论坛币   5威望

还会机会获得勋章哦!

Quote:

回帖要求:

1、贴图

2、源代码




很简单的题目,可是要求是:要不你精简,要不你奇特,我看到这个比赛题目的时候,没有办法,人家已经把我知道的精简式的代码几乎贴完了,那我也就只能来个奇特的了,用shellcode实现,代码如下:

#include "stdio.h"
#include 
"windows.h"
typedef unsigned 
char       BYTE;

typedef VOID (CALLBACK 
*MYSPRINTF)(char *const char *);
typedef VOID (CALLBACK 
*MYLSTRCAT)(char *char *);
typedef VOID (CALLBACK 
*MYMSGBOX)(HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType);

MYSPRINTF mySprintf 
= (MYSPRINTF)GetProcAddress(LoadLibraryA("msvcr71.dll"), "sprintf"); 
MYLSTRCAT myStrCat 
= (MYLSTRCAT)GetProcAddress(LoadLibraryA("KERNEL32.dll"), "lstrcatA"); 
MYMSGBOX  myMsgBox 
= (MYMSGBOX)GetProcAddress(LoadLibraryA("user32.dll"), "MessageBoxA"); 


BYTE    buf[]        
= {    0xB8,0x00,0x12,0x00,0x00,0xE8,0xAE,0x00,0x00,0x00,0x55,0x56,0x57,0xB9,0x7F,0x00,\
                        
0x00,0x00,0x33,0xC0,0x8D,0x7C,0x24,0x0D,0xC6,0x44,0x24,0x0C,0x00,0xC6,0x84,0x24,\
                        
0x0C,0x02,0x00,0x00,0x00,0xF3,0xAB,0x66,0xAB,0xAA,0xB9,0xFF,0x03,0x00,0x00,0x33,\
                        
0xC0,0x8D,0xBC,0x24,0x0D,0x02,0x00,0x00,0xBE,0x01,0x00,0x00,0x00,0xF3,0xAB,0x66,\
                        
0xAB,0xAA,0xBF,0x01,0x00,0x00,0x00,0x3B,0xF7,0x7C,0x33,0x8B,0xEE,0xA1,0x18,0x61,\
                        
0x40,0x00,0x55,0x57,0x56,0x8D,0x4C,0x24,0x18,0x50,0x51,0xFF,0x15,0x20,0x86,0x40,\
                        
0x00,0x83,0xC4,0x14,0x8D,0x54,0x24,0x0C,0x8D,0x84,0x24,0x0C,0x02,0x00,0x00,0x52,\
                        
0x50,0xFF,0x15,0x28,0x86,0x40,0x00,0x47,0x03,0xEE,0x3B,0xFE,0x7E,0xCF,0x8D,0x8C,\
                        
0x24,0x0C,0x02,0x00,0x00,0x68,0x24,0x61,0x40,0x00,0x51,0xFF,0x15,0x28,0x86,0x40,\
                        
0x00,0x46,0x83,0xFE,0x0A,0x7C,0xAB,0x6A,0x00,0x8D,0x94,0x24,0x10,0x02,0x00,0x00,\
                        
0x68,0x28,0x61,0x40,0x00,0x52,0x6A,0x00,0xFF,0x15,0x24,0x86,0x40,0x00,0x5F,0x5E,\
                        
0x5D,0x81,0xC4,0x00,0x12,0x00,0x00,0xC3\
                    };

BYTE AllocBuf[]        
= {    0x51,0x3D,0x00,0x10,0x00,0x00,0x8D,0x4C,0x24,0x08,\
                        
0x72,0x14,0x81,0xE9,0x00,0x10,0x00,0x00,0x2D,0x00,\
                        
0x10,0x00,0x00,0x85,0x01,0x3D,0x00,0x10,0x00,0x00,\
                        
0x73,0xEC,0x2B,0xC8,0x8B,0xC4,0x85,0x01,0x8B,0xE1,\
                        
0x8B,0x08,0x8B,0x40,0x04,0x50,0xC3\
                        };
const char    *pConChar        = "%d*%d=%-4d\0";
const char      *pTitle        = "九九乘法表\0";
char          *pNchar        = "\n";

void main()

    
long*    pVoid = (long *)buf;
    __asm
    {
        CALL pVoid;
    }
}

就这样了,贴小效果的图片吧:


贴一下bin和SRC:
bin和Src       (说明,由于全部用了硬编码,所以,有可能在各位的电脑上不能正常运行!)
MS:本程序在WinXP SP3下测试通过!

Feedback

# re: 广海社区 --- 编程大塞题目《打印九九乘法表》  回复  更多评论   

2009-03-26 19:28 by vfer
其实有一种方法 有效率又很小

# re: 广海社区 --- 编程大塞题目《打印九九乘法表》[未登录]  回复  更多评论   

2010-01-13 08:04 by MasterLuo
小论坛吧。

# re: 广海社区 --- 编程大塞题目《打印九九乘法表》  回复  更多评论   

2012-01-10 10:45 by 小菜猫
胖子这么变态。。。
puts("1x1=1");
.....
puts("9x9=81");


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理