CodeForces 7A Kalevitch and Chess
来源:互联网 发布:权威数据网站 编辑:程序博客网 时间:2024/04/30 02:01
大概意思是要找出输入的方阵中B的行与列的数量,使用二位数组去储存,然后遍历所有列与排。
需要注意的是这里如果全是B的话,output的是8。
java代码如下:
import java.util.Scanner;public class Main{public static void main(String[] args) {Scanner sc = new Scanner(System.in);String[] str = new String[8];char[][] ch = new char[8][8];int i,j,num = 0,count1 = 0,count2 = 0;for(i =0;i < 8;i++)str[i] = sc.next();for(i = 0;i <8;i++){for(j = 0;j < 8;j++){ch[i][j] = str[i].charAt(j);}}for(i=0;i<8;i++){num = 0;for(j=0;j<8;j++){if(ch[i][j] == 'B')num++;if(num == 8)count1++;}}for(i=0;i<8;i++){num = 0;for(j=0;j<8;j++){if(ch[j][i] == 'B')num++;if(num == 8)count2++;}}if(count1 == 8 || count2 == 8)System.out.println(8);elseSystem.out.println(count1 + count2);}}
0 0
- codeforces 7A - Kalevitch and Chess
- Codeforces 7A Kalevitch and Chess
- CodeForces 7A Kalevitch and Chess
- CodeForces 7A Kalevitch and Chess
- CodeForces 7A Kalevitch and Chess
- codeforces 7 A. Kalevitch and Chess
- CodeForces 7A - Kalevitch and Chess
- CodeForces 7A Kalevitch and Chess
- Codeforces 7A Kalevitch and Chess
- 7A Kalevitch and Chess
- Codeforces Beta Round #7 A. Kalevitch and Chess
- CodeForces - 7A Kalevitch and Chess(搜索?!模拟!)
- A. Kalevitch and Chess
- code forces 7A Kalevitch and Chess
- 【取巧遍历】#7 A. Kalevitch and Chess
- CF 7A Kalevitch and Chess
- cf 7a Kalevitch and Chess
- A. Kalevitch and Chess【思维】
- java int数组的包含
- LeetCode:Distinct Subsequences
- 第二章作业
- 目前几种常见穿NAT的方法分析
- 作业2.30
- CodeForces 7A Kalevitch and Chess
- Linux启动过程详解
- 欢迎使用CSDN-markdown编辑器
- 重建表决磁盘和OCR文件
- Python入门——石头剪刀布程序
- css中float left与float right的使用说明
- google学术登陆不上的解决办法
- php下发短信验证码60秒简单验证
- iOS:获取点击坐标