導航:首頁 > 源碼編譯 > 五的源碼是多少

五的源碼是多少

發布時間:2022-07-28 08:18:05

1. -5的原碼、反碼和補碼各是多少啊,5呢

-5的原碼、反碼和補碼各是10000101、11111010和11111011。

5的原碼、反碼和補碼各是00000101、01111010和01111011。

計算機中的存儲系統都是用2進制儲存的,對我們輸入的每一個信息它都會自動轉變成二進制的形式,而二進制在存儲的時候就會用到原碼,反碼和補碼。

例如:輸入25

原碼就是:0000000000011001

反碼: 1111111111100110

補碼: 1111111111100111

(1)五的源碼是多少擴展閱讀:

補碼是為了計算方便而發明的。原始計算器只能做加法不能做減法,但是科學家發現,例如7+(-5)=2可以這樣算:7+(-5) = 7+(10000-5)-10000 = 10002 - 10000 = 2 。

這很奇怪,因為機器太傻,只能做加法,但是雖然不會減法,-10000還是很方便的,只要去掉開頭的1;用10000減也是很方便的,因為可以用9999減然後+1,而用9999減,只要把每一位用9減。

2. java五子棋源代碼

我這有演算法 不過沒做swing界面 DOS下可以直接運行 要不你拿去改改
import java.io.BufferedReader;
import java.io.InputStreamReader;

/*
* 五子棋源碼
* 所用的符號標識 ○ ● ┼
* 在dos界面下運行效果最佳
* 黑白雙方交叉輸入落子點坐標 以逗號隔開如 1,1
* 輸入空 或者一方勝出 程序停止
*/
public class Chess {
// 定義棋盤大小
private static int SIZE = 15;
private String[][] board;

public static void main(String[] args) throws Exception {
Chess chess = new Chess();
// 初始化棋盤
chess.initBoard();
// 畫出棋盤
chess.paintBoard();
// 根據who的奇偶性 判斷該誰落子
int who = 0;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String str = null;
while ((str = br.readLine()) != null) {
// 提取輸入的 以","分開的數 分別對應x y坐標
String[] posStr = str.split(",");
int x = Integer.parseInt(posStr[0]);
int y = Integer.parseInt(posStr[1]);
// 判斷落子點是否合法
if (!"┼".equals(chess.board[x][y])) {
System.out.println("這里不允許落子,請重下..");
continue;
}
if (who % 2 == 0) {
chess.board[x][y] = "○";
chess.paintBoard();
// 判斷是否勝出
if (chess.isWin("○")) {
System.out.println("○獲勝");
return;
}
} else {
chess.board[x][y] = "●";
chess.paintBoard();
// 判斷是否勝出
if (chess.isWin("●")) {
System.out.println("●獲勝");
return;
}
}

who++;
}
}

// 以 "┼" 初始化棋盤
public void initBoard() {
board = new String[SIZE][SIZE];
for (int i = 0; i < SIZE; i++) {
for (int j = 0; j < SIZE; j++) {
board[i][j] = "┼";
}
}
}

// 描繪出當前棋盤
public void paintBoard() {
// 以下代碼 這里為了使得棋盤坐標看的清楚 加入了坐標值
System.out.print(" ");
for (int i = 0; i < SIZE; i++) {
if (i < 10) {
System.out.print(i + " ");
} else {
System.out.print((i - 10) + " ");
}
}
System.out.println();
// 以上代碼 這里為了使得棋盤坐標看的清楚 加入了坐標值
for (int i = 0; i < SIZE; i++) {
if (i < 10) {
System.out.print(" " + i);
} else {
System.out.print(i);
}
for (int j = 0; j < SIZE; j++) {
System.out.print(board[i][j]);
}
System.out.println();

}
}

// 判斷是否獲勝
public boolean isWin(String sign) {
int count = 0;
// 橫向掃描各行
// 有一個sign的子 計數器+1
// 碰到不是sign的子 計數器置零
// 計數器到達5時 返回true 勝出
for (int i = 0; i < SIZE; i++) {
count = 0;
for (int j = 0; j < SIZE; j++) {
if (board[i][j].equals(sign)) {
count++;
if (count == 5) {
return true;
}
} else {
count = 0;
}
}
}
// 縱向掃描各列
// 方法同上
for (int i = 0; i < SIZE; i++) {
count = 0;
for (int j = 0; j < SIZE; j++) {
if (board[j][i].equals(sign)) {
count++;
if (count == 5) {
return true;
}
} else {
count = 0;
}
}
}
// 掃描斜右下
// 在橫向掃描基礎上 外層套一個循環 以k為標識
// 坐標x-y的范圍在-SIZE+1到SIZE-1之間
// 當x-y的值相等時 在同一右下斜線上
for (int k = -SIZE + 1; k <= SIZE - 1; k++) {
count = 0;
for (int i = 0; i < SIZE; i++) {
for (int j = 0; j < SIZE; j++) {
if (i - j == k) {
if (board[i][j].equals(sign)) {
count++;
if (count == 5) {
return true;
}
} else {
count = 0;
}
}
}
}
}
// 掃描斜左邊上
// 方法同上 坐標x+y的值相等時 在同一左上斜線上
for (int k = -SIZE + 1; k <= SIZE - 1; k++) {
count = 0;
for (int i = 0; i < SIZE; i++) {
for (int j = 0; j < SIZE; j++) {
if (i + j == k) {
if (board[i][j].equals(sign)) {
count++;
if (count == 5) {
return true;
}
} else {
count = 0;
}
}
}
}
}

return false;
}

}

3. 請問 -5 的補碼是1010還是1011

-5
原碼:1101
反碼(在原碼基礎上,符號位不變,其它位都取反):1010
補碼(在反碼基礎上,加1):1011

此處僅僅是用四位二進制來示負整數的情況
因為-5+5=0.
而1011+0101=0.所以就是1011

4. c語言五子棋代碼,

我只給你判斷輸贏的演算法,其他的你自己解決//全局變數
int curX,curY;//當前下棋的坐標 0 <= curX <= 15 0 <= curY <= 15
int onTable[16][16];
void WhoWin(int collor)
{ // 豎直方向 水平方向 右上到左下 左上到右下
if( SameLineNum(0,1) >= 5 ||SameLineNum(1,0) >= 5 ||SameLineNum(1,1) >= 5 ||SameLineNum(-1,1) >= 5)
{ printf("%s 方獲勝\n",collor);
}
}//判斷當前棋子的某個方向上同色棋子有多少
int SameLineNum(int x,int y)
{
int tX,tY;
int num;//同一線上相同顏色棋子數
tX = curX;tY = curY;
do//計算落子一邊同顏色的棋子數 (比如左邊)
{ if( onTable(tX,tY) <> onTable(curX,curY)
{ num = Max(Abs(curX - tX),Abs(curY - tY);//Max求最大值,Abs求求絕對值
break;
}
tX = tX + x;tY = tY + y;
}
while (x < 0 || j < 0 || i > 15 || j > 15);
do//計算落子一邊同顏色的棋子數 (比如右邊)
{ if( onTable(tX,tY) <> onTable(curX,curY)
{ num = num -1 + Max(Abs(curX - tX),Abs(curY - tY);//Max求最大值,Abs求求絕對值
break;
}
tX = tX - x;tY = tY - y;
}
while (x < 0 || j < 0 || i > 15 || j > 15);
return num;
}

5. c ++五子棋源代碼

其實,只需要做少量工作就可以了,判斷下棋的人當前落子處,附近是否存在五子連珠就可以了,也就是4個方向(米字型),判斷一下落子處附近是否有五子連珠就可以了

6. 五子棋源代碼

發那裡?

7. Maroon 5 - Sugar源碼是多少

我覺得結婚不適合吧,唱bruno mars的marry

8. 急求五子棋源代碼

/*
五子棋
*/

#include<stdio.h>
#include<stdlib.h>
#include<graphics.h>
#include<bios.h>
#include<conio.h>

#define LEFT 0x4b00
#define RIGHT 0x4d00
#define DOWN 0x5000
#define UP 0x4800
#define ESC 0x011b
#define SPACE 0x3920

#define BILI 20
#define JZ 4
#define JS 3
#define N 19

int box[N][N];
int step_x,step_y ;
int key ;
int flag=1 ;

void draw_box();
void draw_cicle(int x,int y,int color);
void change();
void judgewho(int x,int y);
void judgekey();
int judgeresult(int x,int y);
void attentoin();

void attention()
{
char ch ;
window(1,1,80,25);
textbackground(LIGHTBLUE);
textcolor(YELLOW);
clrscr();
gotoxy(15,2);
printf("游戲操作規則:");
gotoxy(15,4);
printf("Play Rules:");
gotoxy(15,6);
printf("1、按左右上下方向鍵移動棋子");
gotoxy(15,8);
printf("1. Press Left,Right,Up,Down Key to move Piece");
gotoxy(15,10);
printf("2、按空格確定落棋子");
gotoxy(15,12);
printf("2. Press Space to place the Piece");
gotoxy(15,14);
printf("3、禁止在棋盤外按空格");
gotoxy(15,16);
printf("3. DO NOT press Space outside of the chessboard");
gotoxy(15,18);
printf("你是否接受上述的游戲規則(Y/N)");
gotoxy(15,20);
printf("Do you accept the above Playing Rules? [Y/N]:");
while(1)
{
gotoxy(60,20);
ch=getche();
if(ch=='Y'||ch=='y')
break ;
else if(ch=='N'||ch=='n')
{
window(1,1,80,25);
textbackground(BLACK);
textcolor(LIGHTGRAY);
clrscr();
exit(0);
}
gotoxy(51,12);
printf(" ");
}
}
void draw_box()
{
int x1,x2,y1,y2 ;
setbkcolor(LIGHTBLUE);
setcolor(YELLOW);
gotoxy(7,2);
printf("Left, Right, Up, Down KEY to move, Space to put, ESC-quit.");
for(x1=1,y1=1,y2=18;x1<=18;x1++)
line((x1+JZ)*BILI,(y1+JS)*BILI,(x1+JZ)*BILI,(y2+JS)*BILI);
for(x1=1,y1=1,x2=18;y1<=18;y1++)
line((x1+JZ)*BILI,(y1+JS)*BILI,(x2+JZ)*BILI,(y1+JS)*BILI);
for(x1=1;x1<=18;x1++)
for(y1=1;y1<=18;y1++)
box[x1][y1]=0 ;
}

void draw_circle(int x,int y,int color)
{
setcolor(color);
setlinestyle(SOLID_LINE,0,1);
x=(x+JZ)*BILI ;
y=(y+JS)*BILI ;
circle(x,y,8);
}

void judgekey()
{
int i ;
int j ;
switch(key)
{
case LEFT :

if(step_x-1<0)
break ;
else
{
for(i=step_x-1,j=step_y;i>=1;i--)
if(box[i][j]==0)
{
draw_circle(step_x,step_y,LIGHTBLUE);
break ;
}
if(i<1)break ;
step_x=i ;
judgewho(step_x,step_y);
break ;
}
case RIGHT :

if(step_x+1>18)
break ;
else
{
for(i=step_x+1,j=step_y;i<=18;i++)
if(box[i][j]==0)
{
draw_circle(step_x,step_y,LIGHTBLUE);
break ;
}
if(i>18)break ;
step_x=i ;
judgewho(step_x,step_y);
break ;
}
case DOWN :

if((step_y+1)>18)
break ;
else
{
for(i=step_x,j=step_y+1;j<=18;j++)
if(box[i][j]==0)
{
draw_circle(step_x,step_y,LIGHTBLUE);
break ;
}
if(j>18)break ;
step_y=j ;
judgewho(step_x,step_y);
break ;
}
case UP :

if((step_y-1)<0)
break ;
else
{
for(i=step_x,j=step_y-1;j>=1;j--)
if(box[i][j]==0)
{
draw_circle(step_x,step_y,LIGHTBLUE);
break ;
}
if(j<1)break ;
step_y=j ;
judgewho(step_x,step_y);
break ;
}
case ESC :
break ;

case SPACE :
if(step_x>=1&&step_x<=18&&step_y>=1&&step_y<=18)
{
if(box[step_x][step_y]==0)
{
box[step_x][step_y]=flag ;
if(judgeresult(step_x,step_y)==1)
{
sound(1000);
delay(1000);
nosound();
gotoxy(30,4);
if(flag==1)
{
setbkcolor(BLUE);
cleardevice();
setviewport(100,100,540,380,1);
/*定義一個圖形窗口*/
setfillstyle(1,2);
/*綠色以實填充*/
setcolor(YELLOW);
rectangle(0,0,439,279);
floodfill(50,50,14);
setcolor(12);
settextstyle(1,0,5);
/*三重筆劃字體, 水平放?5倍*/
outtextxy(20,20,"The White Win !");
setcolor(15);
settextstyle(3,0,5);
/*無襯筆劃字體, 水平放大5倍*/
outtextxy(120,120,"The White Win !");
setcolor(14);
settextstyle(2,0,8);
getch();
closegraph();
exit(0);
}
if(flag==2)
{
setbkcolor(BLUE);
cleardevice();
setviewport(100,100,540,380,1);
/*定義一個圖形窗口*/
setfillstyle(1,2);
/*綠色以實填充*/
setcolor(YELLOW);
rectangle(0,0,439,279);
floodfill(50,50,14);
setcolor(12);
settextstyle(1,0,8);
/*三重筆劃字體, 水平放大8倍*/
outtextxy(20,20,"The Red Win !");
setcolor(15);
settextstyle(3,0,5);
/*無襯筆劃字體, 水平放大5倍*/
outtextxy(120,120,"The Red Win !");
setcolor(14);
settextstyle(2,0,8);
getch();
closegraph();
exit(0);
}
}
change();
break ;
}
}
else
break ;
}
}

void change()
{
if(flag==1)
flag=2 ;
else
flag=1 ;
}

void judgewho(int x,int y)
{
if(flag==1)
draw_circle(x,y,15);
if(flag==2)
draw_circle(x,y,4);
}

int judgeresult(int x,int y)
{
int j,k,n1,n2 ;
while(1)
{
n1=0 ;
n2=0 ;
/*水平向左數*/
for(j=x,k=y;j>=1;j--)
{
if(box[j][k]==flag)
n1++;
else
break ;
}
/*水平向右數*/
for(j=x,k=y;j<=18;j++)
{
if(box[j][k]==flag)
n2++;
else
break ;
}
if(n1+n2-1>=5)
{
return(1);
break ;
}

/*垂直向上數*/
n1=0 ;
n2=0 ;
for(j=x,k=y;k>=1;k--)
{
if(box[j][k]==flag)
n1++;
else
break ;
}
/*垂直向下數*/
for(j=x,k=y;k<=18;k++)
{
if(box[j][k]==flag)
n2++;
else
break ;
}
if(n1+n2-1>=5)
{
return(1);
break ;
}

/*向左上方數*/
n1=0 ;
n2=0 ;
for(j=x,k=y;j>=1,k>=1;j--,k--)
{
if(box[j][k]==flag)
n1++;
else
break ;
}
/*向右下方數*/
for(j=x,k=y;j<=18,k<=18;j++,k++)
{
if(box[j][k]==flag)
n2++;
else
break ;
}
if(n1+n2-1>=5)
{
return(1);
break ;
}

/*向右上方數*/
n1=0 ;
n2=0 ;
for(j=x,k=y;j<=18,k>=1;j++,k--)
{
if(box[j][k]==flag)
n1++;
else
break ;
}
/*向左下方數*/
for(j=x,k=y;j>=1,k<=18;j--,k++)
{
if(box[j][k]==flag)
n2++;
else
break ;
}
if(n1+n2-1>=5)
{
return(1);
break ;
}
return(0);
break ;
}
}

void main()
{
int gdriver=VGA,gmode=VGAHI;
clrscr();
attention();
initgraph(&gdriver,&gmode,"c:\\tc");
/* setwritemode(XOR_PUT);*/
flag=1 ;
draw_box();
do
{
step_x=0 ;
step_y=0 ;
/*draw_circle(step_x,step_y,8); */
judgewho(step_x-1,step_y-1);
do
{
while(bioskey(1)==0);
key=bioskey(0);
judgekey();
}
while(key!=SPACE&&key!=ESC);
}
while(key!=ESC);
closegraph();
}



9. 求PHP5源碼,當前時間減用戶注冊時間得出多少天數距離。

你真正學過MYSQL嗎?
MYSQL裡面的SQL語句就完全可以解決你的問題 無須寫PHP判斷

閱讀全文

與五的源碼是多少相關的資料

熱點內容
自助洗車有什麼app 瀏覽:935
程序員離職率多少 瀏覽:322
程序員那麼可愛電視劇今天沒更新 瀏覽:337
我的世界地形演算法 瀏覽:343
台灣dns的伺服器地址雲空間 瀏覽:288
音樂噴泉軟體要什麼加密狗 瀏覽:501
androidhttpmime 瀏覽:774
威科夫操盤法pdf 瀏覽:981
演算法可以用圖表表示 瀏覽:948
山西太原php 瀏覽:273
常用cmd網路命令 瀏覽:676
hashmap7源碼分析 瀏覽:898
搜索引擎原理技術與系統pdf 瀏覽:362
運動估計演算法python 瀏覽:860
java正則1 瀏覽:538
redhatlinux最新 瀏覽:182
python字典編程詞彙 瀏覽:147
微信和伺服器如何通訊 瀏覽:13
百家號伺服器配置有什麼用 瀏覽:601
怎麼為電腦加密 瀏覽:60