一些有趣的程序   (閒着沒事寫點好玩的東西.....)

看了校報,發現有一行挺好玩的代碼,於是做了一些小修改。

  1. int c[]={1398227295,6245697}; 
  2. puts((char *)c); 

 輸出結果是:

 那麼這個數字是怎麼來的呢?

  1. char str[]="_AWSAM_";    
  2. int *a=(int *)str; 
  3. int *b=(int *)(str+4); 
  4. cout<<*a<<endl<<*b<<endl; 
就是這樣來的。。

指針真是靈活啊。。 


突然發神經想知道電腦對我的看法,於是我問電腦:

  1. #include <stdio.h> 
  2. void main() 
  3.  
  4.  
  5. printf("WHAT DO YOU THINK OF AWSAM? \n"); 
  6.  
  7. /// Tell me,please ! \\\ 
  8.  
  9. printf("AWSAM is foolish \n"); 
  10.  
  11. printf("AWSAM is WISER \n"); 
  12.  

然後它告訴我:

 

 

 

 =================================================================

 

//這短短的幾行代碼可以模擬***帝國的那種字符流效果

 

 

 

  1. #include<stdio.h> 
  2. #include <windows.h> 
  3. void main() 
  4.  char * p=(char *)main; 
  5.  int end=(int)main+150000; 
  6. while((int)p<end) 
  7.  printf("%c\t",*p++); 
  8.  Sleep(3); 

////////////////////////////////////////////////////////////////

下雪

  1. #include<stdio.h> 
  2. #include <windows.h> 
  3. #include <time.h> 
  4. void snow(); 
  5. void main() 
  6. snow(); 
  7. void snow() 
  8.  srand(time(NULL)); 
  9.  HDC hdc=CreateDC(TEXT("DISPLAY"),NULL,NULL,NULL); 
  10.   
  11.  for(int x=0;x<90000;x++) 
  12.  { 
  13.  SetPixel(hdc,rand()%1500,rand()%1000,RGB(255,255,255)); 
  14.  Sleep(1); 
  15.  } 
  16.  ReleaseDC(0,hdc); 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章