2014-09-21 41 views
-1

不合格-ID錯誤這是我的代碼:預計用括號

16 using namespace std; 
17 
18 void printInOrder(string s1, string s2, string s3); 
19 
20 int main() 
21 { 
22  string w1, w2, w3;    // input values      
23 
24  cin >> w1 >> w2 >> w3;   // read in three values    
25  printInOrder(w1, w2, w3);  // function does not return anything                   
26 
27  return 0; 
28 
29 } 
30 //                   
31 // printInOrder() prints out the three words in alpha order     
32 //    with spaces between them, no return value     
33 //                   
34 void printInOrder(string x, string y, string z) 
35 { 
36  // your code here             
37  // your function does NOT use return         
38  // Instead, it sends values to cout         
39  // Just print the 3 strings as described in the assignment   
40  // with no extra stuff.            
41 
42  if (x<24 && y<20 && z<24) 
43    cout << x, y, z << endl; 
44 
45    return; 
46 
47 } 

而且我不斷收到錯誤:

mid3.cpp:39:1: error: expected unqualified-id before ‘{’ token 

想不通什麼錯!

謝謝!

+0

On line 39?你確定你正在編譯/顯示正確的文件嗎? – deviantfan 2014-09-21 23:07:53

回答

1

42行,你應該把每個條件放在()中,我不知道你爲什麼要比較字符串和整數! on line 43,you should write:

cout << x << y << z << endl;