Code One:
#include <iostream>using namespace std;void ten_to_two (int num); int main () {int num=10;ten_to_two (num); return 0;} void ten_to_two (int num) {if (num!=0) {int m=num%2;num=num/2;ten_to_two (num); cout<<m;}}
Code two: (Binary recursive algorithm)
#include <iostream>using namespace Std;int leihe (int); float Multiply (int); int main () {int num=4;cout<< Leihe (+) <<endl;cout<< "n!=" <<multiply (num) <<endl;return 0;} int Leihe (int num)//cumulative recursive {if (num!=0) return Leihe (num-1) +num;
Code three: (Decomposition of integer recursive algorithm)
/* Decompose the number */#include <iostream>using namespace std;void resolve (int n); int main () {int m=0;cin>>m;resolve (m); return 0;} void Resolve (int n) {if (n!=0) {int m=n%10;n=n/10;resolve (n); Cout<<m<<endl;}}
Code four: (Decomposition of mass factor recursive algorithm)
#include <iostream>using namespace std;void prime_number (int num, int n) { if (num >=n) {while (num % n) n++;//Find a mass factor num/= n;//divide this factorization if (num>=n) cout<<n<< "*";//print this factorization else cout <<n; Prime_number (num,n); } else Cout<<endl;} int main () { int n,m; cin>>n>>m; for (int i=n;i<=m;i++) { cout<<i<< "="; Prime_number (i,2); } return 0;}
(End of full text)
Some recursive programs