混淆代码中的错误,请解释错误及其输出内容。
void Test(int i)
{
if (i > 1)
{
Test(i / 2);
Test(i / 2);
}
printf("* for %d\n", i);
}
Public void main{
test(5);
}
答案 0 :(得分:1)
此程序中没有错误,如果有问题在线运行[在线编译器https://www.jdoodle.com/c-online-compiler
包括
#include <stdio.h>
void Test(int i)
{
if (i > 1)
{
Test(i / 2);
Test(i / 2);
}
printf("* for %d\n", i);
}
int main(void) {
Test(5);
return 0;
}
输出为*为1 *为1 *为2 *为1 *为1 *为2 *为5