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

没问题啊

Posted by KatrineYang at 2016-11-07 00:55:29 on Problem 3589
#include <iostream>
#include <stdio.h>
using namespace std;

int main() {
	int n;
	scanf("%d",&n);
	char c[6],d[6];
	while(n--){
		scanf("%s%s",c,d);
		int A=0,B=0;
		bool cused[4]={0},dused[4]={0};
		for(int i = 0; i < 4; i++){
			if(c[i]==d[i]) {
				A++;
				cused[i]=1,dused[i]=1;
			}
		}
		for(int i = 0; i < 4; i++){
			if(cused[i])continue;
			for(int j = 0; j < 4; j++){
				if(dused[j])continue;
				if(c[i]==d[j]){
					B++;
					cused[i]=1,dused[j]=1;
				}
			}
		}
		printf("%dA%dB\n",A,B);
	}
	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