锘??xml version="1.0" encoding="utf-8" standalone="yes"?>
#include<iostream>
using namespace std;
void wz()
{
cout<<"涓嬮潰寮濮嬩簲瀛愭姣旇禌錛屼竴鍙烽夋墜鐢ㄦ柟鍧楃鍙鳳紝浜屽彿鐢ㄥ績(jī)鍨嬬鍙?"<<endl<<endl;
for(int i=3;i>0;i--)
{
cout<<i<<" ";
}
cout<<"寮濮?----------"<<endl<<endl;
}
int hs()
{
int x,y,i=0,j=1;
char d[80][80];
//鍒濆鍖?--
for(x=0;x<25;x+=3)
{
for(y=0;y<80;y+=3)
{
d[x][y]='+';
}
}
//絎竴琛屾暟瀛?-
for(x=0;x<10;x++)
cout<<x<<" ";
for(x=10;x<27;x++)
cout<<x<<" ";
cout<<endl;
//杈撳嚭媯嬬洏--
for(x=0;x<25;x+=3)
{
cout<<j<<" ";j++;
for(y=0;y<76;y+=3)
{
cout<<d[x][y]<<" ";
}
cout<<endl;
}
while(1)
{
int a,b;
if(i%2==0)
cout<<"鐢辯帺瀹朵竴涓嬫錛?<<endl;
else
cout<<"鐢辯帺瀹朵簩涓嬫錛?<<endl;
cin>>a>>b;
if(i%2==1)
{
if(d[(a-1)*3][(b-1)*3]=='+')
d[(a-1)*3][(b-1)*3]=3;
else
{
cout<<"-----------------------------涓嶈兘瑕嗙洊媯嬪瓙:"<<endl;
continue;
}
}
else
{
if(d[(a-1)*3][(b-1)*3]=='+')
d[(a-1)*3][(b-1)*3]=1;
else
{
cout<<"-----------------------------涓嶈兘瑕嗙洊媯嬪瓙:"<<endl;
continue;
}
}
i++;
j=1;
//絎竴琛屾暟瀛?--
for(x=0;x<10;x++)
cout<<x<<" ";
for(x=10;x<27;x++)
cout<<x<<" ";
cout<<endl;
for(x=0;x<25;x+=3)
{
cout<<j<<" ";j++;
for(y=0;y<76;y+=3)
{
cout<<d[x][y]<<" ";
}
cout<<endl;
}
//鍒ゆ柇鏄惁鏄簲涓?br /> if(//妯潃
d[(a-1)*3][(b-1)*3]==1&&d[(a-1)*3][(b)*3]==1&&d[(a-1)*3][(b+1)*3]==1&&d[(a-1)*3][(b+2)*3]==1&&d[(a-1)*3][(b+3)*3]==1
||d[(a-1)*3][(b-2)*3]==1&&d[(a-1)*3][(b-1)*3]==1&&d[(a-1)*3][(b)*3]==1&&d[(a-1)*3][(b+1)*3]==1&&d[(a-1)*3][(b+2)*3]==1
||d[(a-1)*3][(b-3)*3]==1&&d[(a-1)*3][(b-2)*3]==1&&d[(a-1)*3][(b-1)*3]==1&&d[(a-1)*3][(b)*3]==1&&d[(a-1)*3][(b+1)*3]==1
||d[(a-1)*3][(b-4)*3]==1&&d[(a-1)*3][(b-3)*3]==1&&d[(a-1)*3][(b-2)*3]==1&&d[(a-1)*3][(b-1)*3]==1&&d[(a-1)*3][(b)*3]==1
||d[(a-1)*3][(b-5)*3]==1&&d[(a-1)*3][(b-4)*3]==1&&d[(a-1)*3][(b-3)*3]==1&&d[(a-1)*3][(b-2)*3]==1&&d[(a-1)*3][(b-1)*3]==1
//浠庡乏涓婂埌鍙充笅
||d[(a-1)*3][(b-1)*3]==1&&d[a*3][b*3]==1&&d[(a+1)*3][(b+1)*3]==1&&d[(a+2)*3][(b+2)*3]==1&&d[(a+3)*3][(b+3)*3]==1
||d[(a-2)*3][(b-2)*3]==1&&d[(a-1)*3][(b-1)*3]==1&&d[a*3][b*3]==1&&d[(a+1)*3][(b+1)*3]==1&&d[(a+2)*3][(b+2)*3]==1
||d[(a-3)*3][(b-3)*3]==1&&d[(a-2)*3][(b-2)*3]==1&&d[(a-1)*3][(b-1)*3]==1&&d[a*3][b*3]==1&&d[(a+1)*3][(b+1)*3]==1
||d[(a-4)*3][(b-4)*3]==1&&d[(a-3)*3][(b-3)*3]==1&&d[(a-2)*3][(b-2)*3]==1&&d[(a-1)*3][(b-1)*3]==1&&d[a*3][b*3]==1
||d[(a-5)*3][(b-5)*3]==1&&d[(a-4)*3][(b-4)*3]==1&&d[(a-3)*3][(b-3)*3]==1&&d[(a-2)*3][(b-2)*3]==1&&d[(a-1)*3][(b-1)*3]==1
//浠庡彸涓婂埌宸︿笅
||d[(a-1)*3][(b-1)*3]==1&&d[(a-2)*3][b*3]==1&&d[a-3][b+1]==1&&d[a-4][b+2]==1&&d[a-5][b+3]==1
||d[a*3][(b-2)*3]==1&&d[(a-1)*3][(b-1)*3]==1&&d[(a-2)*3][b*3]==1&&d[(a-3)*3][(b+1)*3]==1&&d[(a-4)*3][(b+2)*3]==1
||d[(a+1)*3][(b-3)*3]==1&&d[a*3][(b-2)*3]==1&&d[(a-1)*3][(b-1)*3]==1&&d[(a-2)*3][b*3]==1&&d[(a-3)*3][(b+1)*3]==1
||d[(a+2)*3][(b-4)*3]==1&&d[(a+1)*3][(b-3)*3]==1&&d[a*3][(b-2)*3]==1&&d[(a-1)*3][(b-1)*3]==1&&d[(a-2)*3][b*3]==1
||d[(a+3)*3][(b-5)*3]==1&&d[(a+2)*3][(b-4)*3]==1&&d[(a+1)*3][(b-3)*3]==1&&d[a*3][(b-2)*3]==1&&d[(a-1)*3][(b-1)*3]==1
//绔栫潃
||d[(a-1)*3][(b-1)*3]==1&&d[a*3][(b-1)*3]==1&&d[(a+1)*3][(b-1)*3]==1&&d[(a+2)*3][(b-1)*3]==1&&d[(a+3)*3][(b-1)*3]==1
||d[(a-2)*3][(b-1)*3]==1&&d[(a-1)*3][(b-1)*3]==1&&d[a*3][(b-1)*3]==1&&d[(a+1)*3][(b-1)*3]==1&&d[(a+2)*3][(b-1)*3]==1
||d[(a-3)*3][(b-1)*3]==1&&d[(a-2)*3][(b-1)*3]==1&&d[(a-1)*3][(b-1)*3]==1&&d[a*3][(b-1)*3]==1&&d[(a+1)*3][(b-1)*3]==1
||d[(a-4)*3][(b-1)*3]==1&&d[(a-3)*3][(b-1)*3]==1&&d[(a-2)*3][(b-1)*3]==1&&d[(a-1)*3][(b-1)*3]==1&&d[a*3][(b-1)*3]==1
||d[(a-5)*3][(b-1)*3]==1&&d[(a-4)*3][(b-1)*3]==1&&d[(a-3)*3][(b-1)*3]==1&&d[(a-2)*3][(b-1)*3]==1&&d[(a-1)*3][(b-1)*3]==1
)
{
cout<<endl<<"鐜╁涓鑾瘋儨"<<endl;break;
}
if(//妯潃
d[(a-1)*3][(b-1)*3]==3&&d[(a-1)*3][(b)*3]==3&&d[(a-1)*3][(b+1)*3]==3&&d[(a-1)*3][(b+2)*3]==3&&d[(a-1)*3][(b+3)*3]==3
||d[(a-1)*3][(b-2)*3]==3&&d[(a-1)*3][(b-1)*3]==3&&d[(a-1)*3][(b)*3]==3&&d[(a-1)*3][(b+1)*3]==3&&d[(a-1)*3][(b+2)*3]==3
||d[(a-1)*3][(b-3)*3]==3&&d[(a-1)*3][(b-2)*3]==3&&d[(a-1)*3][(b-1)*3]==3&&d[(a-1)*3][(b)*3]==3&&d[(a-1)*3][(b+1)*3]==3
||d[(a-1)*3][(b-4)*3]==3&&d[(a-1)*3][(b-3)*3]==3&&d[(a-1)*3][(b-2)*3]==3&&d[(a-1)*3][(b-1)*3]==3&&d[(a-1)*3][(b)*3]==3
||d[(a-1)*3][(b-5)*3]==3&&d[(a-1)*3][(b-4)*3]==3&&d[(a-1)*3][(b-3)*3]==3&&d[(a-1)*3][(b-2)*3]==3&&d[(a-1)*3][(b-1)*3]==3
//浠庡乏涓婂埌鍙充笅
||d[(a-1)*3][(b-1)*3]==3&&d[a*3][b*3]==3&&d[(a+1)*3][(b+1)*3]==3&&d[(a+2)*3][(b+2)*3]==3&&d[(a+3)*3][(b+3)*3]==3
||d[(a-2)*3][(b-2)*3]==3&&d[(a-1)*3][(b-1)*3]==3&&d[a*3][b*3]==3&&d[(a+1)*3][(b+1)*3]==3&&d[(a+2)*3][(b+2)*3]==3
||d[(a-3)*3][(b-3)*3]==3&&d[(a-2)*3][(b-2)*3]==3&&d[(a-1)*3][(b-1)*3]==3&&d[a*3][b*3]==3&&d[(a+1)*3][(b+1)*3]==3
||d[(a-4)*3][(b-4)*3]==3&&d[(a-3)*3][(b-3)*3]==3&&d[(a-2)*3][(b-2)*3]==3&&d[(a-1)*3][(b-1)*3]==3&&d[a*3][b*3]==3
||d[(a-5)*3][(b-5)*3]==3&&d[(a-4)*3][(b-4)*3]==3&&d[(a-3)*3][(b-3)*3]==3&&d[(a-2)*3][(b-2)*3]==3&&d[(a-1)*3][(b-1)*3]==3
//浠庡彸涓婂埌宸︿笅
||d[(a-1)*3][(b-1)*3]==3&&d[(a-2)*3][b*3]==3&&d[a-3][b+1]==3&&d[a-4][b+2]==3&&d[a-5][b+3]==3
||d[a*3][(b-2)*3]==3&&d[(a-1)*3][(b-1)*3]==3&&d[(a-2)*3][b*3]==3&&d[(a-3)*3][(b+1)*3]==3&&d[(a-4)*3][(b+2)*3]==3
||d[(a+1)*3][(b-3)*3]==3&&d[a*3][(b-2)*3]==3&&d[(a-1)*3][(b-1)*3]==3&&d[(a-2)*3][b*3]==3&&d[(a-3)*3][(b+1)*3]==3
||d[(a+2)*3][(b-4)*3]==3&&d[(a+1)*3][(b-3)*3]==3&&d[a*3][(b-2)*3]==3&&d[(a-1)*3][(b-1)*3]==3&&d[(a-2)*3][b*3]==3
||d[(a+3)*3][(b-5)*3]==3&&d[(a+2)*3][(b-4)*3]==3&&d[(a+1)*3][(b-3)*3]==3&&d[a*3][(b-2)*3]==3&&d[(a-1)*3][(b-1)*3]==3
//绔栫潃
||d[(a-1)*3][(b-1)*3]==3&&d[a*3][(b-1)*3]==3&&d[(a+1)*3][(b-1)*3]==3&&d[(a+2)*3][(b-1)*3]==3&&d[(a+3)*3][(b-1)*3]==3
||d[(a-2)*3][(b-1)*3]==3&&d[(a-1)*3][(b-1)*3]==3&&d[a*3][(b-1)*3]==3&&d[(a+1)*3][(b-1)*3]==3&&d[(a+2)*3][(b-1)*3]==3
||d[(a-3)*3][(b-1)*3]==3&&d[(a-2)*3][(b-1)*3]==3&&d[(a-1)*3][(b-1)*3]==3&&d[a*3][(b-1)*3]==3&&d[(a+1)*3][(b-1)*3]==3
||d[(a-4)*3][(b-1)*3]==3&&d[(a-3)*3][(b-1)*3]==3&&d[(a-2)*3][(b-1)*3]==3&&d[(a-1)*3][(b-1)*3]==3&&d[a*3][(b-1)*3]==3
||d[(a-5)*3][(b-1)*3]==3&&d[(a-4)*3][(b-1)*3]==3&&d[(a-3)*3][(b-1)*3]==3&&d[(a-2)*3][(b-1)*3]==3&&d[(a-1)*3][(b-1)*3]==3
)
{
cout<<endl<<"鐜╁浜岃幏鑳?<<endl;break;
}
}
return 0;
}
int main()
{
char a;
wz();
hs();
while(1)
{
cout<<"鎸塒閲嶆柊寮濮嬶細(xì)";
cin>>a;
if(a=='p')
hs();
else
break;
}
return 0;
}
浜烘満瀵規(guī)垬鏆傛椂娌℃兂鍑烘潵錛屾湁鐭ラ亾鐨勫笇鏈涙寚鏁欎竴涓嬶紒錛佹劅嬋----
鍏堢湅涓嬮潰涓閬?鍙栧弽鍜岀Щ浣嶇浉緇撳悎鐨勯棶棰?/p>
#include<stdio.h>
int main()
{
char a=0x11;
char b;
b=~a<<2;
printf("%d\n",b);
b=~(a<<2);
printf("%d\n",b);
b=~a>>2;
printf("%d\n",b);
b=~(a>>2);
printf("%d\n",b);
return 0;
}
杈撳嚭緇撴灉鏄細(xì)
-72
-69
-5
-5
鍒氬紑濮嬪湪鎯充負(fù)浠涔堢浉鍚岀殑鎿嶄綔錛堝彧鏄Щ浣嶆柟鍚戜笉鍚岋級(jí)錛屼負(fù)浠涔堜笂闈袱涓粨鏋滀笉涓鏍鳳紝鑰屼笅闈袱涓粨鏋滃嵈鏄竴鏍風(fēng)殑鍛€傛湁浜涗漢鍦ㄧ枒闂槸涓嶆槸鍥犱負(fù)涓嬮潰涓や釜琛ㄨ揪寮忛兘鏄厛縐諱綅鍚庡彇鍙嶇殑鍛紵鎴戝彲浠ヨ偗瀹氫笉鏄繖鏍風(fēng)殑錛屼絾鏄笉鑳借В閲婅繖涓粨鏋溿傝繖涓棶棰樻垜綰犵粨浜?jiǎn)鍗婂ぉ锛?nbsp; 涓嶈繃瀵逛笅闈㈢殑鐭ヨ瘑浜?jiǎn)瑙d箣鍚庝究璞佺劧寮鏈椾簡(jiǎn)銆?/p>
縐諱綅榪愮畻絎﹀垎涓哄乏縐昏繍綆楃鍜屽彸縐昏繍綆楃銆?br />褰撳涓涓暟鎵ц宸︾Щ榪愮畻鐨勬椂鍊欙紝鍙寵竟鐨勭┖浣嶆槸鐢?琛ラ綈銆?br />鑰屽綋瀵逛竴涓暟鎵ц鍙崇Щ榪愮畻鐨勬椂鍊欙紝宸﹁竟鐨勭┖浣嶆槸鐢ㄧ鍙蜂綅琛ラ綈鐨勶紙榪欐槸鎴戜箣鍓嶆病娉ㄦ剰鐨勫湴鏂癸紝鎯劎錛夈?/p>
瑙d綋姝ラ濡備笅錛?/p>
a=0x11=0001 0001
~a=1110 1110
a<<2=0100 0100
a>>2=0000 0100
~a<<2=1011 1000
鐜板湪 1011 1000鏄ˉ鐮侊紝杞寲鎴愬師鐮佷箣鍚庢槸
1100 1000=-72 -72鏄崄榪涘埗
~錛坅<<2錛?0100 0100
杞寲涓哄師鐮佷箣鍚庢槸 1100 0101=-69
~a>>2=1111 1011(娉ㄦ剰鐜板湪鏄敤1琛ラ綈鐨勶紝鍥犱負(fù)~a鐨勭鍙蜂綅鏄?)
杞寲涓哄師鐮佷箣鍚庢槸 1000 0101=-5
~錛坅>>2)=1111 1011
杞寲涓哄師鐮佷箣鍚庢槸 1000 0101=-5
鏄庣櫧涔嬪悗蹇?jī)鎯呭緢濂藉Q屾墍浠ュ湪榪欓噷鍒嗕韓涓涓嬨傚懙鍛?br />