Many problems in Volums have such input as follows:
(problem 121 : Pipe Fitters )
Sample Input
3 3
2.9 10
2.9 10.5
11 11
The input has no end flag to tell you where is the end. If it is a file, feof() can be called to judge. However ,it seems to me no way to write a program in C++ to judge there is end if it get on screen. WOuld someone tell me how to do this?
Many thanks
121 - Pipe Fitters
Moderator: Board moderators
-
- New poster
- Posts: 4
- Joined: Sun Jul 02, 2006 5:00 am
-
- Experienced poster
- Posts: 136
- Joined: Fri Apr 15, 2005 3:47 pm
- Location: Singapore
- Contact:
Or use:
Code: Select all
while (cin >> a >> b)
{
// process
}
or something like this:
Code: Select all
while( scanf( "%lf%lf", &a, &b ) == 2 ) ) {
//process
}
-
- Learning poster
- Posts: 63
- Joined: Tue Mar 07, 2006 6:51 pm
- Location: india
hi this link could be useful for solving this problems...
http://www.stetson.edu/~efriedma/cirinsqu/
http://www.stetson.edu/~efriedma/cirinsqu/
Re: #121 - Pipe Fitters
My AC program generates below outputs for the following intputs:
INPUT:
OUTPUT:
Hope it might help
INPUT:
Code: Select all
0.2 128
0.4 128
0.6 128
0.8 128
1 128
1.2 128
1.4 128
1.6 128
1.8 128
2 128
2.2 128
2.4 128
2.6 128
2.8 128
3 128
3.2 128
3.4 128
3.6 128
3.8 128
4 128
4.2 128
4.4 128
4.6 128
4.8 128
5 128
5.2 128
5.4 128
5.6 128
5.8 128
6 128
6.2 128
6.4 128
6.6 128
6.8 128
7 128
7.2 128
7.4 128
7.6 128
7.8 128
8 128
8.2 128
8.4 128
8.6 128
8.8 128
9 128
9.2 128
9.4 128
9.6 128
9.8 128
10 128
Code: Select all
0 grid
0 grid
0 grid
0 grid
128 grid
128 grid
128 grid
147 skew
147 skew
256 grid
256 grid
256 grid
294 skew
383 skew
384 grid
384 grid
384 grid
510 skew
510 skew
515 skew
515 skew
515 skew
638 skew
638 skew
662 skew
662 skew
765 skew
765 skew
765 skew
809 skew
893 skew
893 skew
893 skew
893 skew
956 skew
1020 skew
1020 skew
1029 skew
1029 skew
1148 skew
1148 skew
1148 skew
1176 skew
1275 skew
1275 skew
1275 skew
1275 skew
1323 skew
1403 skew
1403 skew
Re: #121 - Pipe Fitters
By the way what's the output for this:
This input was inspired by the fact sqrt(2) = 1.41, so the answer should be .
However, most of the AC code returns
Code: Select all
2.43 2.43
Code: Select all
5 skew
However, most of the AC code returns
Code: Select all
4 grid