fork(2) download
  1. #include <iostream>
  2. #include "cstring"
  3. #include <cstdlib>
  4. #include <conio.h>
  5. using namespace std;
  6. void decToBin(int);
  7. void binToDec (char *);
  8. int main(int argc, char *argv[]){
  9. if(argc != 3) {
  10. cout << "Using N 2 or N 10, 2/10 - number system. \nExample: 345 2" << endl;
  11. return -1;
  12. }
  13. int n = 0;
  14. if(atoi(argv[2])==2){
  15. decToBin(atoi(argv[1]));
  16. }
  17. cout << "You press not number..";
  18. if(atoi(argv[2])==10){
  19. binToDec(argv[1]);
  20. }
  21. cout << "Number system mb 2 or 10.";
  22. getch();
  23. return 0;
  24.  
  25. }
  26.  
  27. void decToBin(int num){
  28. int t=0;
  29. while(num){
  30. num=num/2;
  31. t=num%2;
  32. cout<<t;
  33. }
  34. cout<<endl;
  35. }
  36.  
  37. void binToDec (char * c) {
  38. int rez=0;
  39. int a=1;
  40. int len=strlen(c);
  41.  
  42. for(int j = 0, k = len; j < len; j++, k-- )
  43. if ( c[ j ] == '1' ) rez |= a << k - 1;
  44. cout << rez;
  45. };
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:4:19: fatal error: conio.h: No such file or directory
compilation terminated.
stdout
Standard output is empty