SEN 5.4.06

www.guggi.at.tt
Verfügbare Informationen zu "SEN 5.4.06"

  • Qualität des Beitrags: 0 Sterne
  • Beteiligte Poster: Vanice - houwdy
  • Forum: www.guggi.at.tt
  • Forenbeschreibung: Forum vorwiegend zur schnellen Lösung elektronischer Probleme
  • aus dem Unterforum: PROGRAMMIERSPRACHEN
  • Antworten: 6
  • Forum gestartet am: Mittwoch 08.03.2006
  • Sprache: deutsch
  • Link zum Originaltopic: SEN 5.4.06
  • Letzte Antwort: vor 18 Jahren, 24 Tagen, 23 Stunden, 1 Minute
  • Alle Beiträge und Antworten zu "SEN 5.4.06"

    Re: SEN 5.4.06

    Vanice - 04.04.2006, 15:04

    Beispiel 1
    // Aufgabenstellung: Einlesen einer Variablen (V) - Zählen der 1er in (V)

    unsigned int V;
    int counter = 0, i;

    printf("Bitte geben Sie eine positive Zahl ein: ");
    scanf ("%d", &V);

    for (i=0; i<32; i++)
    {
    if(V & (1 << i))
    counter++;
    }

    printf("Die Zahl enthaelt Binaer %d Einsen.", counter);



    Re: SEN 5.4.06

    Vanice - 04.04.2006, 15:05

    Beispiel 2
    // Einlesen einer Variablen - Rotieren nach rechts - Ausgeben

    unsigned int V;
    int i, n;

    printf("Bitte geben Sie eine positive Zahl ein: ");
    scanf ("%d", &V);

    printf("Um wieviele Stellen rotieren?: ");
    scanf ("%d", &n);

    printf("\n\n");
    printf("Bitmuster vorher: ");

    for (i=31;i>=0; i--)
    {
    if(V & (1 << i)) //*
    printf("1"); //*
    else //*
    printf("0"); //*
    }

    for (i=0; i<n; i++)
    V >>= 1;

    printf("\n\n");
    printf("Bitmuster nachher: ");

    for (i=31; i>=0; i--)
    {
    printf("%d",(V&(1<<i))?1:0); //Diese Zeile entspricht dem Bereich mit dem *
    }



    Re: SEN 5.4.06

    Vanice - 04.04.2006, 15:07

    Beispiel 3
    // Binäres Einlesen einer Variablen

    Weiß jemand wie das mit dem Zeichenweiseeinlesen ging?
    Habs vergessen.



    Re: SEN 5.4.06

    Vanice - 04.04.2006, 15:08

    Beispiel 4
    // Einlesen einer Variable (V) - Einlesen einer BitPos - Löschen aller Bit nach BitPos - Ausgabe von V

    unsigned int V, counter = 0;
    int BitPos, i;

    printf("Bitte geben Sie eine positive Zahl ein: ");
    scanf ("%d", &V);

    printf("Bitte geben Sie die Position an, ab der alle Bits 0 sein sollen: ");
    scanf ("%d", &BitPos);
    for (i=31; i>=0; i--)
    {
    printf("%d",(V&(1<<i))?1:0);
    }

    printf("\n\n");

    for(i=0; i<=BitPos; i++)
    {
    if (V & (1<<i))
    counter |= (1<<i);
    }
    V = counter;
    for (i=31; i>=0; i--)
    {
    printf("%d",(V&(1<<i))?1:0);
    }



    Re: SEN 5.4.06

    Vanice - 04.04.2006, 17:36

    Bits
    1011011011 1010101 V
    1010101 counter

    V = counter

    0 & 0 = 0
    0 & 1 = 0
    1 & 0 = 0
    1 & 1 = 1

    0 | 0 = 0
    0 | 1 = 1
    1 | 0 = 1
    1 | 1 = 1

    0 ^ 0 = 0
    0 ^ 1 = 1
    1 ^ 0 = 1
    1 ^ 1 = 0

    001010100100100101 --> ^ 1 << i (darf nur ein int, long und deren unsigned sein)
    110101011011011010 entspricht der Funktion ~



    Re: SEN 5.4.06

    houwdy - 04.04.2006, 20:36

    Hex Eingabe dez Ausgabe
    #include <stdio.h>

    void main()
    {

    unsigned int i; //Variablendefinition

    printf ("Zahl eingeben");
    scanf ("%x", &i); //Mit %x hexzahl Einlesen


    printf ("Die Zahl %d", i); //Mit %d dezimal ausgeben

    }



    Mit folgendem Code, können Sie den Beitrag ganz bequem auf ihrer Homepage verlinken



    Weitere Beiträge aus dem Forum www.guggi.at.tt

    arrays mit php - gepostet von houwdy am Freitag 27.04.2007
    was is passiert? - gepostet von Anonymous am Mittwoch 22.11.2006
    MOHO 36 Heimbar vom 26.06.07 - gepostet von passer-by am Dienstag 26.06.2007
    Sommerloch - gepostet von passer-by am Dienstag 31.07.2007
    MOHO 20 Heimbar vom 29.03.2006 - gepostet von houwdy am Donnerstag 30.03.2006



    Ähnliche Beiträge wie "SEN 5.4.06"

    Sen Ne Dilersen [Internetten Izle] - blogcuisi (Mittwoch 30.05.2007)
    Toki Sen - Tokisen (Donnerstag 08.03.2007)
    ILLADA SEN - firtina (Montag 02.07.2007)
    Ballade vom Orakel von Sen'jin - Gôthmog (Mittwoch 16.01.2008)
    Nilgün - Sen - Elif (Donnerstag 14.06.2007)
    Ben Ve Sen - meryem (Dienstag 01.05.2007)
    DJ caglar guci ve Tomakinler Sen sen - staylaz (Samstag 04.11.2006)
    NE SEN NE BEN - yeliz (Mittwoch 10.01.2007)
    SEN Test - Vanice (Mittwoch 26.04.2006)
    Golo sagt goodbye Sen Jin - Golo (Dienstag 07.11.2006)