Commit 8b50a90e by Junpeng

unfinished ex0 and finished ex1

parent 9a50c3e1
 # PT1_2021 :q# PT1_2021 Submission of Junpeng's exercise \ No newline at end of file Submission of Junpeng's exercise
 .DS_Store *.out *~ *.a *.aux *.dat *.log *.o *.out *.synctex.gz *.pyc build/ install/ *.swp
hw0/a.out 0 → 100755
hw0/ex1.cpp 0 → 100644
 #include int recur_gcd(int a, int b){ if (b == 0){ return a; } else{ return recur_gcd(b, a % b); } } int loop_gcd(int a, int b){ int t; while (b != 0){ t = b; b = a % b; a = t; } return a; } int main(){ int a,b; a = recur_gcd(18,12); b = loop_gcd(18,12); printf("%i \n %i\n", a,b); return 0; }
hw0/ex2.cpp 0 → 100644
 #include int recur_Fibo(int m){ if (m == 0){ return 0; } else if (m == 1){ return 1; } else{ return recur_Fibo(m-1) + recur_Fibo(m-2); } } int loop_Fibo(int m){ int k = 0; int a = 0; // F_{n-2} int b = 1; // F_{n-1} if (m == 0){ k = 0; } else if (m == 1){ k = 1; } else{ for (int i = 1; i < m; i++){ a = b; b = a; k = a + b; } } return k; } int main(){ int a, b; a = recur_Fibo(82); b = loop_Fibo(82); printf("%i \n %i \n", a, b); return 0; }
hw1/a.out 0 → 100755