可能重复:
无法解决有关此代码的难题......
以下是一段C代码,其目的是打印减号20次.但你可以注意到,它不起作用.
#include <stdio.h>
int main()
{
int i;
int n = 20;
for( i = 0; i < n; i-- )
printf("-");
return 0;
}
Run Code Online (Sandbox Code Playgroud)
修好上面的代码很简单.要使问题变得有趣,您必须通过更改一个字符来修复上述代码
如果我要求一个人在他的脑海中选择1到1200之间的数字.如果我只能提出他只会回答"是"或"否"的问题,那么在我得到他在脑海中选择的号码的答案之前,我需要问多少个问题?
我正在寻找尽可能少的问题.任何经过验证的解决方案都是可观的
考虑以下功能
计算上述功能将花费14次操作
int function1(int a,int b,int c, int d, int e)
{
int returnNumber;
//int no = randomNumber(); //Some Random Number Generator Function , Lets Assume the cost of this function to be 0 for simplicity purpose
switch(randomNumber())
{
case 0: returnNumber = a+b; // costs 6 Operations , Case Check costs 1, assignment costs 1 and addition costs 4
break;
case 1: returnNumber = c+d; // Costs 6 Operations
break;
default: returnNumber = e; // costs …
Run Code Online (Sandbox Code Playgroud) 编写符合要求的程序会议的方法是什么:
有空主(只返回0)即
int main(int argc, char** argv) {
return 0;
}
Run Code Online (Sandbox Code Playgroud)main
必须包含除上述代码之外的其他代码.
根据C语言的官方说明,将返回什么号码?
int a, b;
a = 5;
b = a+++++a;
return b;
Run Code Online (Sandbox Code Playgroud)