English 中文(简体)
我是否错过了东西?
原标题:Have I missed something?

我只字不提一些快速的假想游戏法,但我却继续犯“超标不合格”错误。

我检查了所有半殖民地,但也许我会错过一些东西?

我的守则如下:

#include <iostream>
#include <stdlib.h>  // srand

using std::cout;
using std::endl;
using std::cin;

int main(void) {
/* code goes here */
srand (time(NULL));
int number = rand() % 100+1;
int guess = 0;

cout << number << endl; /* debug */

do {
/* code goes here */
cout << "Guess a number between 1 and 100: ";
cin >> guess;

if ( guess > number ) { cout << "Too high, try again. 
" << endl;}
else if ( guess < number ) { cout << "Too low, try again. 
" << endl; }
else { cout << "That s right! 
" << endl; }

exit(0);
} // fi
while  ((number));! std:: = guess);
return (0); }
// main }`

此处为错误案文:

ERROR!
/tmp/3NFruHJf2U.cpp: In function  int main() :
/tmp/3NFruHJf2U.cpp:27:27: error: expected unqualified-id before  =  token
27 | while  ((number));! std:: = guess);
  |                           ^
问题回答

值得注意的是:

while(number != guess);

www.un.org/Depts/DGACM/index_french.htm

页: 1 st: = gues;

以上线正显示错误。 在左边,关键词后面的括号中的表述是决定该 lo是否离开的决定表述。

In the above line, the exit condition decision making expression is while ((number)); ---> because the line has been closed by the parenthesis and the semicolon denotes that the while statement has ended. Hence the expression following the semi colon(;) has no significance for the while loop exit condition. So I don t understand why you have written ! std:: = guess); after the semi colon. There is a parenthesis at the end of the expression. So have you missed any brackets or have you misplaced the semi colon in between? Please check the code in the perspective.

Also std is a standard C++ library which provides you many in built functionalities. For using any in built functionality of std library we have to use that in the given format std::. For e.g. if you want to display something to console you have to use the cout function defined in std library and the usage is std::cout In your code, after std:: nothing is seen, which I think is technically wrong. Help me to understand what you are trying to do which helps me to give better suggestions.

Thanks, Praveen





相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签