Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Empfohlene Antworten

Veröffentlicht

Folgende Frage

:marine

ich geb in C eine Zahl(als Zweierkomplementär) ein.

BSP: 0000 0111 und diese Zahl soll auch genau so ausgegeben werden.

Gehts?? und wenn ja was tun????

gruß Harry

:marine :marine

folgenden Befehl gebe ich ein

int dual;

scanf("&i",&dual);

hier belibt mir bei einer eingabe von "0000 0011" die "11".

Tja, die 11 von 00000011 bleibt, weil Du dezimal einliest. Du könntest aber in einen String einlesen und dann Zeichen für Zeichen abklappern, um von binär nach dezimal umwandeln.



#include <stdio.h>


int bin2val(const char *binary)
{
int val = 0;

while(*binary)
val = (val << 1) + (*binary++ == '1' ? 1 : 0);
return val;
}


int main(void)
{
char binstr[128]; // should be big enough

scanf("%s", binstr);
printf("%i\n", bin2val(binstr));

return 0;
}


[/PHP]

ok, full ack! ... aber mal ehrlich: mit meiner Lösung kann man viel besser angeben ;-)

Erstelle ein Konto oder melde dich an, um einen Kommentar zu schreiben.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.