From 4f5c47bea7854c5d1b2909d387187c64a3cec01d Mon Sep 17 00:00:00 2001 From: Ren Baoshuo Date: Thu, 6 Aug 2020 01:40:29 +0800 Subject: [PATCH] =?UTF-8?q?P1320=20=E5=8E=8B=E7=BC=A9=E6=8A=80=E6=9C=AF?= =?UTF-8?q?=EF=BC=88=E7=BB=AD=E9=9B=86=E7=89=88=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit R36448319 --- problem/P1320/P1320.cpp | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 problem/P1320/P1320.cpp diff --git a/problem/P1320/P1320.cpp b/problem/P1320/P1320.cpp new file mode 100644 index 00000000..cc8761ce --- /dev/null +++ b/problem/P1320/P1320.cpp @@ -0,0 +1,37 @@ +// R36448319 + +#include + +using namespace std; + +int main() { + int n, c; // n: 题意中的N, c: count + char l; // 上一个出现的字符 + string s[205]; // 数组 + + n = c = 0; + l = '0'; + + cin >> s[0]; + n = s[0].size(); + for(int i = 1 ; i < n ; i++) { + cin >> s[i]; + } + + cout << n << " "; + + for(int i = 0 ; i < n ; i++) { + for(int j = 0 ; j < n ; j++) { + if(s[i][j] == l) { + c++; + } else { + cout << c << " "; // 输出以前统计完的 + c = 1; // 坑点: 这里一定要赋值为1, 因为当前字符也算 + l = s[i][j]; // 设置当前字符为继续统计对象 + } + } + } + cout << c << endl; // 坑点: 要输出最后一个统计 + + return 0; +}