poj3589
来源:互联网 发布:临沂拓普网络拖欠工资 编辑:程序博客网 时间:2024/06/05 21:00
题目大意:
给出两个数,前一个数是X想的数,后一个数是Y猜的数,输出格式是A*B,A前面表示位置正确,值也正确的数量,B前的*表示值正确但是位置的数量
解题思路:
对比+遍历即可
代码如下:
#include<stdio.h>#include<stdlib.h>#include<string.h>int main(){ char str1[5],str2[5]; int t,i,j; int countp,countv; scanf("%d",&t); while(t--) { countp=countv=0; scanf("%s%s",str1,str2); for(i=0;i<4;i++) { if(str1[i]==str2[i]) { countp++; } else { for(j=0;j<4;j++) { if(str1[i]==str2[j]&&(i!=j)) { countv++; } } } } printf("%dA%dB\n",countp,countv); } return 0;}
0 0
- poj3589
- poj3589
- POJ3589 Number-guessing Game
- 北大ACM poj3589 Number-guessing Game
- poj3536
- Java常见问题分析(内存溢出、内存泄露、线程阻塞等)
- poj2965 The Pilots Brothers' refrigerator —— 技巧性
- Linux字符界面和图形界面
- Docker学习笔记四:在容器中管理数据
- poj3589
- Debug与Release版本的区别详解
- 17 - 05 - 16 HTML( <div> 标签)
- poj3619
- NodeJS常用模块介绍
- poj3632
- poj3637
- 寒假篇39
- 母函数 初步刷题