Panel użytkownika
Nazwa użytkownika:
Hasło:
Nie masz jeszcze konta?

Błąd "case label '2' not within a switch statement"

Ostatnio zmodyfikowano 2015-12-22 19:21
Autor Wiadomość
michi223456
Temat założony przez niniejszego użytkownika
Błąd "case label '2' not within a switch statement"
» 2015-12-22 19:09:56
Witam, mam następujące błędy:
case label '2' not within a switch statement
case label '3' not within a switch statement
case label '4' not within a switch statement
case label '5' not within a switch statement
case label not within a switch statement
A mój kod programu to:
C/C++
#include <cstdio>
#include <iostream>
#include <math.h>
#include <string>
using namespace std;
int main( void )
{
    int liczba1, liczba2, cyfra;
    int t;
    int i, o;
    int y;
    int polecenie;
    int wiek;
    int test;
    char liczba;
    float a;
    float b;
    bool porownanie = 123 >= 321;
    polecenie = 0;
    cout << "Witaj!" << endl;
    cout << "Ile masz lat?" << endl;
    cin >> wiek;
    if( wiek >= 18 )
    {
        cout << "A więc twierdzisz, ze jestes pelnoletni :)" << endl;
        cout << "A tak naprawde, nikogo to nie interesuje XD" << endl;
    }
    else
    {
        cout << "A wiec jestes na to za mlody..." << endl;
        return 0;
    }
    cout << "Sprawdzmy czy nie jestes robotem :)" << endl;
    cout << "Ile to 2 + 2 ?" << endl;
    cin >> test;
    if( test == 4 )
    {
        cout << "Gratuluje! przechodzisz do kolejnego etapu... ;)" << endl;
    }
    if( test != 4 )
    {
        cout << "Przykro Mi, ale sie mylisz..." << endl;
        return 0;
    }
    cout << "porownanie = " << porownanie << endl;
    cout << "porownanie = " <<( 111 != 222 ) << endl;
    cout << "porownanie = " <<( 666 == 666 ) << endl;
    cout << "porownanie = " <<( 862 < 123 ) << endl;
    cout << "Teraz troche angielskiego :)" << endl;
    printf( "Testing " );
    std::cout << "Seven ";
    std::cout << "or" << std::endl;
    cout << "7" << endl;
    cout << "Let's try" << endl;
    cout << "Type seven" << endl;
    cin >> a;
    if( a == 7 )
    {
        cout << "Now type 7 again" << endl;
    }
    if( a != 7 )
    {
        cout << "Porazka, naucz sie angielskiego..." << endl;
        return 0;
    }
    cin >> b;
    if( b == 7 )
    {
        cout << "Seven is not bigger than 7" << endl;
        cout << "Because 7 - 7 is " << a - b << endl;
    }
    if( b != 7 )
    {
        cout << "Porazka, naucz sie angielskiego..." << endl;
        return 0;
    }
    cout << "..." << endl;
    cout << "#############################################" << endl;
    cout << "Gratuluje, udało Ci się przejść próbny test" << endl;
    cout << "#############################################" << endl;
    cout << "Witaj w aplikacji kalkulator 1.0" << endl;
    cout << "Jesteśmy zadowoleni, ze zamiast wylaczyc odrazu program wykonales tamten idiotyczny test :)" << endl;
    do
    {
        cout << "1. Dodawanie..." << endl;
        cout << "2. Odejmowanie..." << endl;
        cout << "3. Mnozenie..." << endl;
        cout << "4. Dzielenie..." << endl;
        cout << "5. Wyjdz..." << endl;
       
        cin >> polecenie;
       
        switch( polecenie )
        case 1
    : cout << "Podaj pierwszą liczbę: " << endl;
        cin >> i;
        cout << "+" << endl;
        cin >> o;
        cout << "Wynik to " << i + o << endl;
        break;
    case 2:
        cout << "Podaj pierwszą liczbę: " << endl;
        cin >> i;
        cout << "-" << endl;
        cin >> o;
        cout << "Wynik to " << i - o << endl;
        break;
    case 3:
        cout << "Podaj pierwszą liczbę: " << endl;
        cin >> i;
        cout << "*" << endl;
        cin >> o;
        cout << "Wynik to " << i * o << endl;
        break;
    case 4:
        cout << "Podaj pierwszą liczbę: " << endl;
        cin >> i;
        cout << "/" << endl;
        cin >> o;
        cout << "Wynik to " << i / o << endl;
        break;
    case 5:
        break;
    default:
        cout << "Error 404 :)" << endl;
    }
    while( polecenie != 5 );
   
    std::cout << "No to do widzenia!";
    return 0;
}
P-142258
Kaikso
» 2015-12-22 19:21:16
Kod w
switch(...)
 daj w klamry
C/C++
switch(...)
{
    // Kod
}
P-142260
« 1 »
  Strona 1 z 1