All pastes #279021 Raw Edit

Something

public text v1 · immutable
·published 2006-12-14 16:57 UTC
rendered paste body
#include <iostream>
#include <math.h>
#include <conio.h>

using namespace std;

int main()
{
  int rest,i,e,zahld,zwischenspeicher; 
  char zahlh[13];
  i=11;
  cout << "Bitte eine dezimale Zahl eingeben.\n";
  cin >> zahld;
  zwischenspeicher=zahld;
  for(e=13;e>=0;e--){zahlh[e]=' ';}
  zahlh[12]='\0';
  while(zwischenspeicher>=1. && i>=0)
    {
    rest=fmod(zwischenspeicher,16);
    zwischenspeicher=floor(zwischenspeicher/16);
    switch (rest)
      {
      case 10:
        zahlh[i]='A';
        break;
      case 11:
        zahlh[i]='B';
        break;
      case 12:
        zahlh[i]='C';
        break;
      case 13:
        zahlh[i]='D';
        break;
      case 14:
        zahlh[i]='E';
        break;
      case 15:
        zahlh[i]='F';
        break;
      case 9:
        zahlh[i]='9';
        break;
      case 8:
        zahlh[i]='8';
        break;
      case 7:
        zahlh[i]='7';
        break;
      case 6:
        zahlh[i]='6';
        break;
      case 5:
        zahlh[i]='5';
        break;
      case 4:
        zahlh[i]='4';
        break;
      case 3:
        zahlh[i]='3';
        break;
      case 2:
        zahlh[i]='2';
        break;
      case 1:
        zahlh[i]='1';
        break;
      case 0:
        zahlh[i]='0';
        break;
      }
    i--;
    }
  cout << "Die Zahl " << zahld << " entspricht im hexadezimalen Sytem der Zahl ";
  for(e=0;e<12;e++){ if (zahlh[e]!=' '){cout << zahlh[e];}}
  cout << "\n";
  getch();
  return 0;
}