下列程式執行時會崩潰,請找出錯誤並改正,並且說明原因。
#include
#include
typedef struct tnode;
tnode* root=null;
int main()
tnode* newnode=(tnode *)malloc(sizeof(tnode));
newnode->value=n;
if(root==null)else
if(n>=temp.value)
temp.left=newnode;
else
temp.right=newnode;
return;}}
#include
#include
tnode *root=null;
int main()
tnode* newnode=(tnode *)malloc(sizeof(tnode));
newnode->value=n;
if(root==null)else
}
gcc (gcc) 3.2.2 20030222 (red hat linux 3.2.2-5)
執行過程:
[explover@explover 20081101]$ gcc -g finderr.c -o finderr
[explover@explover 20081101]$ ./finderr
(本人水平有限,不足之處,請大家多多指正,謝謝!)
面試題解 二 之Sony 筆試題
題目 完成程式,實現對陣列的降序排序 include void sort int main 數字任意給出 sort return 0 void sort include int array 10 int i sort array,sizeof array sizeof array 0 1 for i...
面試題解 五 之聯想筆試題
設計函式 int atoi char s include include int main void int atoi const char s return symbol 1 v v gcc gcc 3.2.2 20030222 red hat linux 3.2.2 5 執行過程 explove...
筆試面試題
1 昨天參加一公司筆試,給幾道演算法題整懵了,其實也不難,但好久沒有碰演算法,只是有思路,要讓我在這麼短的時間內寫出程式來還是不行。2 這裡將其中一道稍微複雜一點的演算法題寫下來,以此小結。3 4 題目描述 5 將n個雞蛋放入到m個籃子中去 n m 保證每個籃子中至少乙個雞蛋,然後指定乙個數x,要求...