三角形的识别

Description
这是一个很简单的问题,就是给有一个打印好的三角形.但我们需要知道它有多少行和列. 其中三角形的图形如下:
Input
只有一组测试数据,如上面图形类似的一个三角形。见sample input
Output
输出只有一行,为其行数row(row>=2)和列数col(col>= 2*row),两个数字间隔一个空格;见sample output

Sample Input

0000000000000000000000000
0000000000000000000000000
0000000000001000000000000
0000000000011100000000000
0000000000111110000000000
0000000001111111000000000
0000000011111111100000000
0000000111111111110000000
0000001111111111111000000
0000011111111111111100000
0000111111111111111110000
0001111111111111111111000
0000000000000000000000000
0000000000000000000000000

00000000000000000000
00000000000000000000
0000000001000000000
0000000011100000000
0000000111110000000
0000001111111000000
0000011111111100000
0000111111111110000
0001111111111111000
0011111111111111100
00000000000000000000
00000000000000000000

Sample Output

10 19
8 15
#include <iostream>
#include <string>
using namespace std;
int main()
{
 string s;
 int col=0,row=0,len,count,i;
 while(cin>>s)
 {
  count=0;
  len=s.length();
  for (i=0;i<=len;i++)
  if (s[i]=='1') count++;
  if (count>0) row++;
  if (count>col) col=count;
  }
 cout<<row<<" "<<col<<endl;
  return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值