Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- using namespace std;
- /*
- int fact(int n)
- {
- if (n <= 1)
- return 1;
- else
- return n*fact(n-1);
- }
- int _tmain(int argc, _TCHAR* argv[])
- {
- int n;
- printf("n=");
- scanf("%d", &n);
- printf("n! = %d", fact(n));
- }
- */
- //задача 24
- /*
- int find(int decimalNum)
- {
- if (decimalNum == 0)
- return 0;
- else
- return (decimalNum % 2 + 10 * find(decimalNum / 2));
- }
- int main()
- {
- int decimalNum = 10;
- printf("%d\n", find(decimalNum));
- return 0;
- }
- */
- //varıant 2
- void toBin(int decimal){
- if(decimal <= 0){
- return;
- }
- if(decimal > 0){
- toBin(decimal/2);
- printf("%d\n", decimal % 2);
- }
- }
- int _tmain(int argc, _TCHAR* argv[]){
- toBin(10);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement