Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:贴代码

Posted by forestgump2012 at 2022-02-07 16:16:08 on Problem 2993
In Reply To:贴代码 Posted by:dw_tanshunwen at 2012-12-06 01:02:48
#include<stdio.h>
#include<string.h>

char str[9][9];

void deal(char *in,int add){
	int row,col,len=strlen(in);
	char ty='P'+add;
	int k;
	for(k=7;k<len;k++){
		if(in[k]>='a' && in[k]<='h'){
			col=in[k]-'a'+1;
		}else if(in[k]>='B' && in[k]<='R'){
			ty=in[k]+add;
		}else if(in[k]>='1' && in[k]<='8'){
			row=9-(in[k]-'0');
			str[row][col]=ty;
			ty='P'+add;
		}
	}
}
void outline()
{
	for(int i=0;i<33;i++){
		if(i%4==0) printf("+");
		else printf("-");
	}
	printf("\n");
}

int main()
{
	
	char line[240];
	int i,j;
//	freopen("in.txt","r",stdin);
//	freopen("out","w",stdout);
	// init
	for(i=1;i<=8;i++){
		for(j=1;j<=8;j++){
			if((i+j)%2==0){
				str[i][j]='.';
			}else{
				str[i][j]=':';
			}
		}
	}
	//white
	gets(line);
	deal(line,0);
	//black
	gets(line);
	deal(line,32);
    //print
	outline();
	for(i=1;i<=8;i++){
		printf("|");
		for(j=1;j<=8;j++){
			if((i+j)%2==0){
				printf(".%c.|",str[i][j]);
			}else{
				printf(":%c:|",str[i][j]);
			}
		}
		printf("\n");
		outline();
	}
    return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator