Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include<iostream>
- #include <fstream>
- using namespace std;
- ofstream fout;
- int fib(int a){
- if (a == 0)
- return 0;
- if (a == 1)
- return 1;
- return fib(a - 1) + fib(a - 2);
- }
- int fact(int n){
- if (n == 0)
- return 1;
- return n*fact(n - 1);
- }
- char str[8];
- int generate(int pos, int size){
- if (pos == size){
- str[pos] = '\0';
- fout << str << endl;
- }
- else{
- for (int i = 0; i < 32; i++)
- {
- if (pos == 0) cout << endl << i << endl;
- if (pos == 1) cout << i << ' ';
- str[pos] = 'a' + i;
- generate(pos + 1, size);
- }
- }
- }
- int _tmain(int argc, _TCHAR* argv[])
- {
- fout.open("pass.txt");
- cout << fib(0)<<endl;
- cout << fact(3) << endl;
- generate(0, 4);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement