看了校報,發現有一行挺好玩的代碼,於是做了一些小修改。
- 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);
- }