Page 3 of 3
How to know the end of input parameters?
Posted: Tue Jul 25, 2006 1:30 pm
by foolishzhu
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
Posted: Tue Jul 25, 2006 2:05 pm
by jan_holmes
just use :
Code: Select all
while (scanf("%lf %lf",&a,&b) != EOF) {
//process
}
Hope it helps...

Posted: Tue Jul 25, 2006 8:32 pm
by jtmh
Or use:
Code: Select all
while (cin >> a >> b)
{
// process
}
Posted: Fri Aug 11, 2006 5:33 pm
by brahle
or something like this:
Code: Select all
while( scanf( "%lf%lf", &a, &b ) == 2 ) ) {
//process
}
Posted: Mon Feb 26, 2007 1:52 pm
by mukeshtiwari
hi this link could be useful for solving this problems...
http://www.stetson.edu/~efriedma/cirinsqu/
Re: #121 - Pipe Fitters
Posted: Mon Jul 21, 2008 6:04 pm
by hasib_bd
My AC program generates below outputs for the following intputs:
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
OUTPUT:
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
Hope it might help
Re: #121 - Pipe Fitters
Posted: Fri Aug 06, 2010 12:29 pm
by serur
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