注册 登录
编程论坛 C++教室

为什么我的cin没显示让我输入

qweiuy566 发布于 2016-10-17 21:23, 1873 次点击
#include<stdio.h>
#include<iostream>
#include<malloc.h>
using namespace std;
typedef struct node  //循环双向链表
{
    int data,len;   //数据
    struct node *prior;//前驱   
    struct node *next; //后继
}Node;
void create(Node *L);  //建立双向链表
void shuchu(Node *L); //输出顺序表中的元素的值
void insert(Node *L,int i,int x); //在位置i插入元素x
main()
{     char ch;
    int a,b;
    Node *L;   //表头指针
    create(L);
    while((ch=getchar())!='#')
    {
        cout<<"输入'A'或'a'是插入元素"<<endl;
        cout<<"输入'#'结束"<<endl;
        switch (ch)
        {
            case 'A':  cout<<"在位置i插入元素x: "<<endl;
            cin>>a;  cin>>b;  insert(L,a,b);
        }
    }
}
1 回复
#2
rjsp2016-10-18 08:45
这代码……
第二次读取的是回车字符
1