看了校报,发现有一行挺好玩的代码,于是做了一些小修改。
- int c[]={1398227295,6245697};
- puts((char *)c);
输出结果是:
那么这个数字是怎么来的呢?
就是这样来的。。
- char str[]="_AWSAM_";
- int *a=(int *)str;
- int *b=(int *)(str+4);
- cout<<*a<<endl<<*b<<endl;
指针真是灵活啊。。
突然发神经想知道电脑对我的看法,于是我问电脑:
- #include <stdio.h>
- void main()
- {
- printf("WHAT DO YOU THINK OF AWSAM? \n");
- /// Tell me,please ! \\\
- printf("AWSAM is foolish \n");
- printf("AWSAM is WISER \n");
- }
然后它告诉我:
=================================================================
//这短短的几行代码可以模拟黑客帝国的那种字符流效果
- #include<stdio.h>
- #include <windows.h>
- void main()
- {
- char * p=(char *)main;
- int end=(int)main+150000;
- while((int)p<end)
- {
- printf("%c\t",*p++);
- Sleep(3);
- }
- }
////////////////////////////////////////////////////////////////
下雪
- #include<stdio.h>
- #include <windows.h>
- #include <time.h>
- void snow();
- void main()
- {
- snow();
- }
- void snow()
- {
- srand(time(NULL));
- HDC hdc=CreateDC(TEXT("DISPLAY"),NULL,NULL,NULL);
- for(int x=0;x<90000;x++)
- {
- SetPixel(hdc,rand()%1500,rand()%1000,RGB(255,255,255));
- Sleep(1);
- }
- ReleaseDC(0,hdc);
- }