Search found 17 matches

by Yile
Tue Dec 26, 2006 4:35 pm
Forum: C++
Topic: Why we can use "while(cin >> a)"
Replies: 6
Views: 3090

Where is the operator defined? The class hierarchy is as follows:

Code: Select all

basic_istream->basic_ios->ios_base
Which class is it defined in? I'm afraid I can't find it.
by Yile
Tue Dec 26, 2006 1:37 pm
Forum: C++
Topic: Why we can use "while(cin >> a)"
Replies: 6
Views: 3090

Why we can use "while(cin >> a)"

I read some manual and find that the operator >> returns *this, the type should be istream&. Then why can we put it in the while statement as a condition?
by Yile
Sat Jan 21, 2006 5:53 pm
Forum: C++
Topic: Why this compile error?
Replies: 1
Views: 1367

Oh, I've found the error. How careless I am.
I'm sorry.
by Yile
Sat Jan 21, 2006 5:47 pm
Forum: C++
Topic: Why this compile error?
Replies: 1
Views: 1367

Why this compile error?

#include <iostream> using namespace std; template <class ValueType> class ZKTreeNode{ private: ValueType m_value; ZKTreeNode<ValueType>* m_parent; ZKTreeNode<ValueType>* m_lch; ZKTreeNode<ValueType>* m_rch; public: ZKTreeNode(){ m_parent = NULL; m_lch = NULL; m_rch = NULL; } ZKTreeNode<ValueType>* ...
by Yile
Wed Jun 08, 2005 1:44 pm
Forum: C++
Topic: A very simple program about "cin", What's the matt
Replies: 3
Views: 1894

Thank you very much! :)
by Yile
Tue Jun 07, 2005 4:04 pm
Forum: C++
Topic: A very simple program about "cin", What's the matt
Replies: 3
Views: 1894

A very simple program about "cin", What's the matt

#include <iostream.h> void main(){ int a; while(true){ cin>>a; if(cin.fail()){ cout<<"error"<<endl; cin.clear(); } else{ break; } } } When the input is a Why the output is error error error error error error error error error error error ... I do use the cin.clear()! But why still the cin doesn't w...
by Yile
Tue May 17, 2005 7:57 am
Forum: C++
Topic: Watch this simple program. What happens?
Replies: 8
Views: 3189

Oh, I see. I can use cin.fail() to see whether there is an input error, and use cin.clear to make the cin>> work again.
Thank you.
by Yile
Tue May 10, 2005 11:58 am
Forum: C++
Topic: Question about "iostream"
Replies: 0
Views: 1382

Question about "iostream"

My C program runs well. But when I modify it to C++ version, it doesn't work. The reason is that I don't understand the "iostream" very well. This is my program which is used to input a Tree from keyboard. For example: if the tree is: 1 / 2 / \ 3 4 Then I can input : (1 (2 (3 () () ) (4 () () ) ) ()...
by Yile
Tue Apr 19, 2005 12:34 pm
Forum: Volume 100 (10000-10099)
Topic: 10004 - Bicoloring
Replies: 93
Views: 29423

I think the job of this problem is: to find if there is a circle(a path from one node to itself) of odd edges.
by Yile
Thu Mar 24, 2005 11:36 am
Forum: Volume 100 (10000-10099)
Topic: 10011 - Where Can You Hide?
Replies: 58
Views: 12679

Please read my algorithm , and help me to find the bug, or if it losts precision. /*all the datas are of long double type*/ infinity=9999999999; if(x_tree==0) k_tree=infinity; else k_tree=y_tree/x_tree; if(k_tree==infinity) { k_R=sqrt(y_tree*y_tree-r_tree*r_tree)/r_tree; k_L=k_R*-1.0; /*k_L and k_R ...
by Yile
Thu Mar 24, 2005 6:47 am
Forum: Volume 100 (10000-10099)
Topic: 10004 - Bicoloring
Replies: 93
Views: 29423

I use Floyd-Worshall to search if there is any circle (a path from a node to itself) with odd nodes. If there is, return no. And I get AC.
by Yile
Wed Mar 23, 2005 12:02 pm
Forum: Volume 100 (10000-10099)
Topic: 10011 - Where Can You Hide?
Replies: 58
Views: 12679

Another question:
If the result is 0.00000001, should I print 0.000 of 0.001? I mean though the distance is very little, but at least it exists. And 0.000 means the house can not be protected. That is not suitable to the distance less than 0.0005.
by Yile
Wed Mar 23, 2005 11:19 am
Forum: Volume 100 (10000-10099)
Topic: 10011 - Where Can You Hide?
Replies: 58
Views: 12679

10011, help

Input:

Code: Select all

9
5 5 1 12 12
20 0 3 7 -7
-9.6 4.3 2.1 -19.2 7.9
5 5 5 11 5
5 5 5 0.1 6.42
5 5 5 0.1 5.998
5 5 5 0.0005 10
20 -24 6 25 -30
-10 2 5 -18 -2
My output:

Code: Select all

2.400
0.000
3.517
1.000
0.100
0.001
0.001
1.810
3.676
Is that right?
Can anyone give me some more test IO?
by Yile
Tue Mar 15, 2005 8:44 am
Forum: Volume 100 (10000-10099)
Topic: 10009 - All Roads Lead Where?
Replies: 60
Views: 14523

Thanks, I've found the bug of my program and got AC. The length of the name doesn't cause the bug as you expect. Thank you again. :)
by Yile
Mon Mar 14, 2005 4:26 pm
Forum: Volume 100 (10000-10099)
Topic: 10009 - All Roads Lead Where?
Replies: 60
Views: 14523

10009

I know the city name is very long. So I just read the first letter of each name and skip the other letters. But still the Runtime Error (SIGSEGV) int case,m,n; char city1,city2,c; scanf("%d",&case); while(case-->0){ scanf("%d %d",&m,&n); c=getchar();/*eat the '\n'*/ while(m-->0){ city1=getchar(); wh...

Go to advanced search