2 shunfurh shunfurh 于 2017.09.03 14:23 提问

Machined Surfaces

An imaging device furnishes digital images of two machined surfaces that eventually will be assembled in contact with each other. The roughness of this final contact is to be estimated.
A digital image is composed of the two characters, "X" and " " (space). There are always 25 columns to an image, but the number of rows, N, is variable. Column one (1) will always have an "X" in it and will be part of the left surface. The left surface can extend to the right from column one (1) as contiguous X's.

Similarly, column 25 will always have an "X" in it and will be part of the right surface. The right surface can extend to the left from column 25 as contiguous X's.

Digital-Image View of Surfaces

     Left                                      Right
     XXXX                                              XXXXX     
     XXX                                             XXXXXXX
     XXXXX                                              XXXX
     XX                                               XXXXXX
     .                                                     .
     .                                                     .
     .                                                     .
     XXXX                                               XXXX
     XXX                                              XXXXXX      
     1                              25

In each row of the image, there can be zero or more space characters separating the left surface from the right surface. There will never be more than a single blank region in any row.

For each image given, you are to determine the total void" that will exist after the left surface has been brought into contact with the right surface. Thevoid" is the total count of the spaces that remains between the left and right surfaces after theyhave been brought into contact.

The two surfaces are brought into contact by displacing them strictly horizontally towards each other until a rightmost "X" of the left surface of some row is immediately to the left of the leftmost "X" of the right surface of that row. There is no rotation or twisting of these two surfaces as they are brought into contact; they remain rigid, and only move horizontally.

Note: The original image may show the two surfaces already in contact, in which case no displacement enters into the contact roughness estimation.

Input

The input consists of a series of digital images. Each image data set has the following format:

First line -
A single unsigned integer, N, with value greater than zero (0) and less than 13. The first digit of N will be the first character on a line.

Next N lines -
Each line has exactly 25 characters; one or more X's, then zero or more spaces, then one or more X's.

The end of data is signaled by a null data set having a zero on the first line of an image data set and no further data.

Output

For each image you receive as a data set, you are to reply with the total void (count of spaces remaining after the surfaces are brought into contact). Use the default output for a single integer on a line.

Sample Input
(character "B" for ease of reading. The actual input file will use the ASCII-space character, not "B").

4
XXXXBBBBBBBBBBBBBBBBXXXXX
XXXBBBBBBBBBBBBBBBXXXXXXX
XXXXXBBBBBBBBBBBBBBBBXXXX
XXBBBBBBBBBBBBBBBBBXXXXXX
2
XXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXX
1
XXXXXXXXXBBBBBBBBBBBBBBXX
0

Sample Output

4
0
0

1个回答

devmiao
devmiao   Ds   Rxr 2017.09.03 22:52
已采纳
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!
其他相关推荐
UVa 414 - Machined Surfaces
题目:n个由X和空格组成的串,两边有至少一个X,将n个串压缩,每次每行消除一个空格,问到不能消除时剩余的空格。 分析:简单题。统计全体空格数sum_b和最少空格数min_b,则结果就是sum_b - n*min_b。 注意:利用gets或者getline读入串。 #include #include #include #include using namespace std;
Machined Surfaces
An imaging device furnishes digital images of two machined surfaces that eventually will be assembled in contact with each other. The roughness of this final contact is to be estimated. A digit
uva 414 Machined Surfaces
An imaging device furnishes digital images of two machined surfaces that eventually will be assembled in contact with each other. The roughness of this final contact is to be estimated. A digital i
UVA 414 - Machined Surfaces
题目链接:  http://uva.onlinejudge.org/index.php?
UVA414 - Machined Surfaces
问题描述 输入多行,每行25个字符,左右为X,中间为空格,当将左边的X平移至与右侧X相连后停止,求平移后之间存在几个空格。 思路ans=总空格数-行数*每行中空格最少的数。注意数据中的B是文中的空格,需要替换。代码#include <cstdio> #include <cstring> #include <iostream> using namespace std; int main() {
UVAOJ 414 - Machined Surfaces
/* 之前一直用C做 对C里面的字符串处理还算比较了解 本以为C++已经做够强大 读取字符串是不会再出现讨厌的缓冲区问题 可后来屡屡碰壁 哎。。。 。。。 总算过了 还算有点收获  */ #define LOCAL #include #include //文件包含一定要写,人家的编译器可不像你用的那么“智能” using namespace std; int a
UVa414 Machined Surfaces
Machined Surfaces  An imaging device furnishes digital images of two machined surfaces thateventually will be assembled incontact with each other. The roughness of this final contact is t
poj 1493 Machined Surfaces
这道题的难点在于读题,题读懂了,基本就是很水很水的题目。。。 题意:每张照片由n行串组成,每行串长度为25,都由X开头,空格中间(也可没有),X结尾。所有串的左边X部分同时右移,直到有一个串没有空格。问这时所有串合起来总共有几个空格。  思路:求最短的空格数min,每一行的空格数减去min之和就是结果了。 AC的代码: #include int blankN
poj1493 Machined Surfaces
题意:真不想吐槽,翻译软件坏了,题读半个小时都都不懂,六级成绩堪忧啊。。 其实就是计算,把左边所有x移到右边与右边最近的x接头,问中间还剩下多少空格。 思路:水题。。计算中间空格最少的数目,每行减去再求和就ok了! ps:  getchar()和初始化不要忘了。。血的教训。。 #include #include #include #include #include #includ
POJ 1493 Machined Surfaces
翻到一道在UVa刷过的题……很偷懒的找出源码交了= = 水题一道……两个机器表面是凹凸不平的,求并在一起后中间缝隙的总大小。 #include int main() { int n,i,j; scanf ("%d",&n); while (n>0) { int x[n],maxx=0,ans=0; for(i=1;i<=n;i+