我有一个简单的问题,我正在学习C编程,我知道!运算符表示逻辑非。我的问题是,在这种情况下,以“做而做”循环为条件是什么意思?是否以某种方式检查变量是否已更改?
我知道我应该以某种方式找到它,但是当我尝试使用Google'!'时,它并不想显示我的意思。
#include <stdio.h>
int main() {
int input, ok=0;
do {
scanf("%d", &input);
if ( /* condition */) {
//the input is wrong it will scan another one
}
else {
//the input is correct, so the while cycle can stop
//we don't need more inputs
ok = 1;
}
} while (!ok);
//...
//...
//...
return 0;
}
Run Code Online (Sandbox Code Playgroud) 我正在写一个程序,我想到一个数字,计算机猜测它.我正在尝试测试它,但我一直都会遇到错误.错误是主题标题.我使用Int.Parse转换我的字符串,但我不知道为什么我收到错误.我知道它说'=='不能和整数一起使用,但是我在网上看到的所有东西以及我班上的幻灯片都使用它,所以我卡住了.代码是不完整的,我不想让它运行,我只是想解决问题.非常感谢任何帮助,谢谢:D
class Program
{
static void Main(string[] args)
{
Console.Write("Enter any number after 5 to start: ");
int answer = int.Parse(Console.ReadLine());
{
Console.WriteLine("is it 3?");
if (answer == "higher")
Run Code Online (Sandbox Code Playgroud) 他们是操作员'+'和' - '来操纵他们操作数的标志吗?
我现在知道我的意思是一元加减运算符!
我以前从未见过这个操作员.
它们是否已在C++ 11或更高版本的C++标准中引入?
有没有办法简化这个表达式:
我想做这个:
d = ( a == "x" ? b : a )
Run Code Online (Sandbox Code Playgroud)
我可以使用三行代码:
d = a;
if(a == "x")
d = b
Run Code Online (Sandbox Code Playgroud)
我能做到这一点的代码/一个表达的一条线,而无需使用一两次?
正如标题所说,&在这个例子中做了什么:
#include <iostream>
using namespace std;
int main()
{
int a = 10;
int b = 13;
int c = a & b;
cout << c << endl;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我的问题是"&"对a&b做了什么,为什么c结果为8?
我目前正在学习本教程,但没有解释"&"运算符.
考虑这个表达式:
x1 = ++x - x++ + --x
Run Code Online (Sandbox Code Playgroud)
如果输入 x 的值 5
java中这种表达式的输出是什么,为什么?
为什么Java输出50时C++输出51相同的代码概念?
int i=5;
i= (++i + ++i + ++i + ++i + ++i + i++);
print i
Run Code Online (Sandbox Code Playgroud)
Java的: 50
C++: 51