需要帮助找到代码中的错误,这些错误是什么以及输出是什么

时间:2017-06-26 15:44:17

标签: c

混淆代码中的错误,请解释错误及其输出内容。

 void Test(int i)
{
 if (i > 1)
 {
 Test(i / 2);
 Test(i / 2);
 }
 printf("* for %d\n", i);
}
Public void main{
test(5);
}

1 个答案:

答案 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