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

hallo

vielleicht kann mir ja jemand helfen, da ich nicht soviel Ahnung vom prgrammiern hab aber am mittwoch muss mein programm stehen...

es geht um einen Fahrkartenautomat:

#include <stdio.h>

#include <conio.h>

#include <windows.h>

#define EKURZ 1.00 /*Variablendeklaration*/

#define EEINZEL 2.00

#define ESTREIFEN 9.00

#define KEINZEL 0.95

#define KSTREIFEN 3.00

typedef enum {EK=1, EE, ES, KE, KS} FAHRKARTE;

void main ()

{

char cEingabe;

double dPreis=0;

FAHRKARTE FWahl;

printf("Es stehen folgende Fahrkarten zur Auswahl:\n\n");

printf("\t <%c> Kurzstrecke Erwachsene: %.2f Euro \n",49,EKURZ);

printf("\t <%c> Einzelfahrt Erwachsene: %.2f Euro \n",50,EEINZEL);

printf("\t <%c> Streifenkarte Erwachsene: %.2f Euro \n",51,ESTREIFEN);

printf("\t <%c> Einzelfahrt Kinder: %.2f Euro \n",52,KEINZEL);

printf("\t <%c> Streifenkarte Kinder: %.2f Euro \n\n",53,KSTREIFEN);

printf("Bitte waehlen Sie eine Fahrkarte: \n\n");

do

{

fflush(stdin);

cEingabe = getch();

switch(cEingabe)

{

case 49:

FWahl=1;

dPreis=EKURZ;

printf("zu zahlender Preis: %.2d Euro\n\n", dPreis);

break;

case 50:

FWahl=2;

dPreis=EEINZEL;

printf("zu zahlender Preis: %.2d Euro\n\n", dPreis);

break;

case 51:

FWahl=3;

dPreis=ESTREIFEN;

printf("zu zahlender Preis: %.2d Euro\n\n", dPreis);

break;

case 52:

FWahl=4;

dPreis=KEINZEL;

printf("zu zahlender Preis: %.2d Euro\n\n", dPreis);

break;

case 53:

FWahl=5;

dPreis=KSTREIFEN;

printf("zu zahlender Preis: %.2d\n\n", dPreis);

break;

default:

printf("Ungueltige Eingabe");

break;

}

printf(" Bestaetigen mit Return, Auswahl wiederholen mit jeder anderen Taste \n\n");

fflush(stdin);

cEingabe=getch();

if (cEingabe!=13)

{

system("cls");

}

}

while (cEingabe!=13);

}

und wenn ich nun debugge kommt beim fahrpreis nur 00, es sollte aber der zu beginn definierte preis stehen :confused:

ja er springt in die schleifen rein gibt aber trotzdem nur 00 aus :confused:

danke danke es funktioniert... :):)

wow, das eine programm geht nun aber ich hätte da noch ein zweites :confused:

die lampe soll bei der schlaterstellung 00 und 11 an sein bei 01 und 10 hingegen aus... falls ich eine andere zahl eingebe, soll er mich solange fragen bis ich 0 od 1 eingebe.. er nimmt aber den wert 1 nicht an:confused:

#include <stdio.h>

#include <stdlib.h>

void main()

{

int iE=-1, iS1=-1, iS2=-1;

do

{

system("cls");

printf("Schalter 1 ist auf Stellung 1 oder 0 ??");

fflush(stdin);

scanf("%d", &iE);

if ((iE==0)||(iE==1))

{iS1 = iE;

}

else

printf("Ungueltige Eingabe\n");

}while (iS1!=(1||0));

do

{

printf("Schalter 2 ist auf Stellung 1 oder 0 ??");

fflush(stdin);

scanf("%d", &iE);

if ((iE==0) || (iE==1))

iS2 = iE;

else

printf("\b");

}while (iS2!=(0||1));

if(iS1==0 && iS2==0)

{

printf (" |\n");

printf (" \\ ** /\n");

printf (" - **** -\n");

printf (" - **** -\n");

printf (" / ** \\\n");

printf (" ##\n");

printf (" ##\n");

}

else {if(iS1==1 && iS2==1)

{

printf (" |\n");

printf (" \\ ** /\n");

printf (" - **** -\n");

printf (" - **** -\n");

printf (" / ** \\\n");

printf (" ##\n");

printf (" ##\n");

}

else

{

printf (" **\n");

printf (" ****\n");

printf (" ****\n");

printf (" **\n");

printf (" ##\n");

printf (" ##\n\n");

}

}

}

while (iS2!=(0||1));
...
while (iS1!=(1||0));[/code] Das geht so nicht. Du musst die Bedingungen, die du mit || verknüpfen willst, beide komplett ausformulieren:
[code]while(iS1!=1 || iS1 != 0)

Aber die Bedingung ist dann immer noch falsch. iS1 ist immer ungleich 1 oder ungleich 0. Oder kannst du mir einen Wert nennen, der beides nicht ist? ;)

Die Negation von

iS1 == 1 || iS1 == 0

ist

iS1 != 1 && iS1 != 0

Für die Zukunft:

Bitte erstelle einen neuen Thread, wenn du eine Frage zu einem anderen Thema hast. Und bitte verwende Code-Tags, damit die Einrückung erhalten bleibt.

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.