getchar()不停止原因

应该是你的输入流中还有残留的字符,getchar()()会接受那个字符。你可以在调用getchar()()之前用fflush(stdin)刷新一下输入缓冲区。
上面一段里面,应该有读入语句吧,没读干净,输入流里还有剩余的字符,就直接被getchar吞掉了,所以没有等待输入。

#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    double f;
    f=(1.0/6)*pow(-1,6);
    cout<<f<<endl;
}

 1 #include<iostream>
 2 using namespace std;
 3 class A
 4 {
 5    public:
 6     virtual void test()
 7     {
 8         cout<<"1"<<endl;
 9     }
10 };
11 class B:public A
12 {
13 public:
14    void test()
15    {
16        cout<<"2"<<endl;
17    }
18 };
19 void F(A *pa,A &ra,A a)
20 {
21    pa->test();
22    ra.test();
23    a.test();
24 }
25 
26 int main()
27 {
28 B b;
29 F(&b,b,b);
30 return 0;
31 }


 
原文地址:https://www.cnblogs.com/Zblogs/p/3285625.html