摘要:
1 Int golf[MAX];2 While(!(cin>>golf[i]))3 {4 cin.clear();5 while(cin.get()! = ‘\n’)6 continue;7 cout<<”Please enter a number:”8 }当输入must i?,则cin表达式将为false,因此不会将任何值放到数组中,而表达式!(cin>>golf[i])将为true,因此进入内部的while循环,该循环的第一条语句使用能够clear()方法重置输入,如果省略这条语句,程序将拒绝继续读取输入。接下来,程序在while循环中使用cin.get 阅读全文
posted @ 2012-09-06 21:03
Asan825
阅读(311)
评论(0)
推荐(0)

浙公网安备 33010602011771号