Guest User

Untitled

a guest
Nov 23rd, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. #include<iostream.h>
  2. #include<math.h>
  3. #include<stdio.h>
  4. #include<string.h>
  5. #include<conio.h>
  6. #include<vcl.h>
  7.  
  8. void main()
  9. {
  10. char a[33],antwort='j';
  11. int auswahl;
  12. long dez;
  13. void DeztoDual(long,char *);
  14.  
  15. while(antwort=='j')
  16. {
  17. printf(" Umwandlungen von Dezi in Dualzahlen\n");
  18. printf(" (1) Dezimalzahl-Dualzahl\n");
  19.  
  20. /* Wenn Menü erwünscht wird1!
  21. do
  22. {
  23. cout <<(" Bitte entsprechende Zahl für da Menü(1,2,3,4,5)auswählen: ");
  24. cin >> auswahl;
  25. if(auswahl != 1) cout <<("\n Falsche Eingabe!");
  26. }
  27. while(auswahl!=1);
  28. */
  29. clrscr();
  30.  
  31. if(true) //Wenn Menü erwünscht wird dann(auswahl=1)
  32. {
  33.  
  34. cout <<(" Umrechnung Dezimalzahl in Dualzahl\n");
  35. cout <<(" Ergebnis beschränkt auf 32 Stellen!\n\n");
  36. cout <<(" Dezimalzahl: ");
  37. cin >> dez;
  38. DeztoDual(dez,a);
  39. cout << " Dualzahl: " << a;
  40. }
  41.  
  42. cout << ("\n\n\n Noch einmal (j/n)? ");
  43. cin >> antwort;
  44. cout <<("\n\n");
  45. clrscr();
  46. }
  47. }
  48.  
  49. void DeztoDual(long dez,char a[])
  50. {
  51. char zeichenlaenge[33]; long result;
  52. a[0]='\0';
  53. while(dez>0)
  54. {
  55. result=dez%2;
  56. if(result==1)
  57. {
  58. strcpy(zeichenlaenge,"1"); //Kopieren eines Strings
  59. }
  60. else
  61. {
  62. strcpy(zeichenlaenge,"0");
  63. }
  64. strcat(zeichenlaenge,a); //strcat hängt an das Ende von dem Ziel
  65. //eine Kopie von der Quelle an.
  66. strcpy(a,zeichenlaenge);
  67. dez/=2;
  68. }
  69. }
Add Comment
Please, Sign In to add comment