【P1320 压缩技术(续集版)】【Java】
作者:互联网
import java.util.Scanner;
public class Main {
static int flag=0,cnt=0;
public static void main(String[]args) {
Scanner in=new Scanner(System.in);
String s=in.next();
int N=s.length();
String[]str=new String[N];
str[0]=s;
for(int i=1;i<N;i++) {
str[i]=in.next();
}
int[]arr=new int[N*N];
for(int i=0;i<N*N;i++) {
arr[i]=str[i/N].charAt(i%N)-48;
}
System.out.print(N+" ");
for(int i=0;i<N*N;i++) {
if(arr[i]==flag%2) {
cnt++;
}else {
System.out.print(cnt+" ");
cnt=1;
flag++;
}
}
if(cnt>0) {
System.out.print(cnt);
}
}
}
标签:cnt,续集,Java,String,arr,int,System,P1320,str 来源: https://blog.csdn.net/m0_57937908/article/details/120931570