Đệ quy (bài thánh gia)

#include<stdio.h> #include<string.h> #include<conio.h> #include<iostream> using namespace std; /* 1 ------------- 1 1 + ------ 1 1+ ----- 1+1 */ float dequy(float n) { if(n==1) return 0.5; return 1/(1+dequy(n-1)); } // đếm số lượng phần tử int dequy1(int n) { if(n==0) return 0; return dequy1(n/10)+1; } int main() { cout<<dequy1(123); system("pause"); return 0; }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.