Witam wyświetla mi się taki error jak w tytule i nie mam pojęcia jak go rozwiązać . Tak tak wiem co to znaczy że ( ma być przed else tylko jak to zrobić tego nie wiem .
dołączam ss
Z góry dziękuje za pomoc
Zamieniłem wszystkie if else na else if i wyskakuje mi takie coś
Następnym razem będę kopiować kod :)
Dla tego wrzuciłem te pytanie na forum .
Tak tak wiem o tym użyłem tam programie użyłem zarówno switch jak i else if :)
Kod wygląda tak:
#include <iostream> #include <time.h> #include <cstdlib> #include <stdio.h> #include <windows.h> #include <conio.h> using namespace std; int war1,znowu; long double x,y; char wybor ; char prze; int main() { cout << "Witaj w aplikacji przelicznik !"<<endl; do { cout << "Co chcesz przeliczy\206 ???" << endl; cout << endl; cout << endl; cout << endl; cout << " MENU " << endl; cout << "--------------------" << endl; cout << "1. Masae" << endl; cout << "2. Dlugo\230\206" << endl; cout << "3. Czas" << endl; cout << "4. Wyj\230cie" << endl; cout << "Wyb\242r:"; wybor=_getch(); if(wybor>'4') { cout << endl; cout << endl; cout << "Nie ma takiej opcji!"<<endl; cout << "Spróbuj ponownie!"<<endl; cout << endl; system("pause"); system("cls"); } } while (wybor>'4' ); system("cls"); switch (wybor) { case '1': { do { cout << "Z jakiej jednostki chcesz przelicza\206" << endl; cout << endl; cout << "MENU PRZELICZNIKA MAS" << endl; cout << "---------------------" << endl; cout << "1. Gramy" << endl; cout << "2. Dekagramy" << endl; cout << "3. Kilogramy" << endl; cout << "4. Tony" << endl; cout << "Wyb\242r: "; cin >> war1; if (war1>4) { cout << endl; cout << "Nie ma takiej opcji!"<<endl; cout << "Spróbuj ponownie!"<<endl; cout << endl; system("pause"); system("cls"); } } while(war1>4); cout << "Podaj warto\230\206: "; cin >> x; system("cls"); ////////////////////////////////////////////////// do { cout << "Na co chcesz przelicza\206" << endl; cout << endl; cout << "MENU PRZELICZNIKA MAS" << endl; cout << "---------------------" << endl; cout << "1. Gramy" << endl; cout << "2. Dekagramy" << endl; cout << "3. Kilogramy" << endl; cout << "4. Tony" << endl; cout << "Wyb\242r:"; prze=_getch(); if (prze>'4') { cout << endl ; cout << "Nie ma takiej opcji!"<<endl; cout << "Spróbuj ponownie!"<<endl; cout << endl; system("pause"); system("cls"); } } while (prze>'4'); system("cls"); switch (prze) { case '1': { if (war1==1) { cout <<x<<"g = "<<x<<"g"; break; } else if (war1==2) { y=x*10; cout <<x<<"dag = "<<y<<"g"; break; } else if (war1==3) { y=x*1000; cout <<x<<"kg = "<<y<<"g"; break; } else if (war1==4); { y=x*1000000; cout <<x<<"t = "<<y<<"g"; break; } system("pause"); } case '2': { if (war1==1) { y=x/10; cout <<x<<"g = "<<y<<"dag"; break; } else if (war1==2) { cout <<x<<"dag = "<<x<<"dag"; break; } else if (war1==3) { y=x*100; cout <<x<<"kg = "<<y<<"dag"; break; } else if (war1==4); { y=x*100000; cout <<x<<"t = "<<y<<"dag"; break; } system("pause"); } case '3': { if (war1==1) { y=x/1000; cout <<x<<"g = "<<y<<"kg"; break; } else if (war1==2) { y=x/100; cout <<x<<"dag = "<<y<<"kg"; break; } else if (war1==3) { cout <<x<<"kg = "<<x<<"kg"; break; } else if(war1==4); { y=x*1000; cout <<x<<"t = "<<y<<"kg"; break; } system("pause"); } case '4': { if (war1==1) { y=x/1000000; cout <<x<<"g = "<<y<<"t"; break; } else if (war1==2) { y=x/100000; cout <<x<<"dag = "<<y<<"t"; break; } else if (war1==3) { y=x/1000; cout <<x<<"kg = "<<y<<"t"; break; } else if(war1==4); { cout <<x<<"t = "<<x<<"y"; break; } } } system("pause"); system("cls"); // cout << "Chcesz jeszcze raz skorzystać z programu" << endl; //cout << endl; //cout << "1. TAK" << endl; //cout << "2. NIE" << endl; //cout << endl; //cout <<"wybór :"; //cin << znowu; //while (znowu==1); } exit(0); case '2': { do { cout << "Z jakiej jednostki chcesz przelicza\206" << endl; cout << endl; cout << "MENU PRZELICZNIKA ODLEGŁOŚCI" << endl; cout << "---------------------" << endl; cout << "1. Milimetry" << endl; cout << "2. Centymetry" << endl; cout << "3. Decymetry" << endl; cout << "4. Metry" << endl; cout << "5. Kilometry " << endl; cout << "Wybierz: "; cout << "Podaj wartość:"; cin >> war1; if (war1>5) { cout << endl; cout << endl; cout << "Nie ma takiej opcji!"<<endl; cout << "Spróbuj ponownie!"<<endl; cout << endl; system("pause"); system("cls"); } } while(war1>5); cout << "Podaj warto\230\206: "; cin >> x; system("cls"); ////////////////////////////////////////////////// do { cout << "Z jakiej jednostki chcesz przelicza\206" << endl; cout << endl; cout << "MENU PRZELICZNIKA ODLEGŁOŚCI" << endl; cout << "---------------------" << endl; cout << "1. Milimetry" << endl; cout << "2. Centymetry" << endl; cout << "3. Decymetry" << endl; cout << "4. Metry" << endl; cout << "5. Kilometry " << endl; cout << "Wybierz: "; prze=_getch(); if (prze>'5') { cout << endl; cout << endl ; cout << "Nie ma takiej opcji!"<<endl; cout << "Spróbuj ponownie!"<<endl; cout << endl; system("pause"); system("cls"); } } while (prze>'5'); system("cls"); switch (prze) { case '1': { if (war1==1) { cout <<x<<"mm = "<<x<<"mm"; break; } else if (war1==2) { y=x*10; cout <<x<<"cm = "<<y<<"mm"; break; } else if (war1==3) { y=x*100; cout <<x<<"dm = "<<y<<"mm"; break; } else if (war1==4) { y=x*1000; cout <<x<<"m = "<<y<<"mm"; break; } else if (war1==5) { y=x*1000000; cout <<x<<"km = "<<y<<"mm"; break; } system("pause"); } case '2': { if (war1==1) { y=x/10; cout <<x<<"mm = "<<y<<"cm"; break; } else if (war1==2) { cout <<x<<"cm = "<<x<<"cm"; break; } else if (war1==3) { y=x*10; cout <<x<<"dm = "<<y<<"cm"; break; } else if (war1==4) { y=x*100; cout <<x<<"m = "<<y<<"cm"; break; } else if (war1==5) { y=x*100000; cout <<x<<"km = "<<y<<"cm"; break; } system("pause"); } case '3': { if (war1==1) { y=x/100; cout <<x<<"mm = "<<y<<"dm"; break; } else if (war1==2) { y=x/10; cout <<x<<"cm = "<<y<<"dm"; break; } else if (war1==3) { cout <<x<<"dm = "<<x<<"dm"; break; } else if(war1==4) { y=x*10; cout <<x<<"m = "<<y<<"dm"; break; } else if (war1==5) { y=x*10000; cout <<x<<"km = "<<y<<"dm"; break; } system("pause"); } case '4': { if (war1==1) { y=x/1000; cout <<x<<"mm = "<<y<<"m"; break; } else if (war1==2) { y=x/100; cout <<x<<"cm = "<<y<<"m"; break; } else if (war1==3) { y=x/10; cout <<x<<"dm = "<<y<<"m"; break; } else if(war1==4) { cout <<x<<"m = "<<x<<"m"; break; } else if (war1==5) { y=x*1000; cout <<x<<"km = "<<y<<"m"; break; } case '5': if (war1==1) { y=x/1000000; cout <<x<<"mm = "<<y<<"km"; break; } else if (war1==2) { y=x/100000; cout <<x<<"cm = "<<y<<"km"; break; } else if (war1==3) { y=x/10000; cout <<x<<"dm = "<<y<<"km"; break; } else if (war1==4) { y=x/1000; cout <<x<<"m = "<<y<<"km"; break; } else if (war1==5) { cout <<x<<"km = "<<x<<"km"; break; } system("pause"); } } } }/////// switche ////////// return 0; }
To znaczy bardzo dobrym treningiem / podsumowaniem umiejętności jest zrobienie aplikacji najpierw w konsoli potem w builderze (ja osobiście ten krok pominąłem) a na końcu w Visual Studio. Aplikacja polega na tym że z pliku wczytujemy pytanie linia 1 i odpowiedź do niego linia 2 i tak dalej, pytania są wybierane randomowo spróbuj zrobić sam taką spkę ale wkleję i kod mojej którą kiedyś zrobiłem ;)
#include <iostream> #include <windows.h> #include <conio.h> #include <cstdlib> #include <fstream> #include <string> #include <math.h> #include <algorithm> #include <time.h> #include "library_in.h" #include "random.h" #include "quests_do.h" using namespace std; int main() { start(); if(setup()==true) ShellExecuteA(0, 0 ,"restore.exe",0,0,SW_HIDE); Sleep(2000); int score_ok=0,score_fail=0,rnd,x; int quests=lines()/2; string quest_str[quests][2]; if(questions(quests,quest_str[0])==false){ cout<<"ERROR -> load";Sleep(5000); } srand(time(NULL)); system("cls"); cout<<"ile ma byc pytan?"<<endl; cin>>x; system("cls"); for(int i=0;i<x;i++){ rnd=random(quests,rnd); if(do_quest(rnd,random(2,-1),true,quest_str[0])==true) score_ok++; else score_fail++; getch(); system("cls"); } system("cls"); cout<<score_fail<<" zle"<<endl<<score_ok<<" dobze"; return 0; }
#include <iostream> #include <windows.h> #include <conio.h> #include <cstdlib> #include <fstream> #include <string> #include <math.h> #include <algorithm> using namespace std; bool setup(){ fstream file; file.open("settings.txt",ios::in); if(file.good()== false) return false; file.close(); file.clear(); file.open("quests.txt",ios::in); if(file.good()== false) return false; file.close(); file.clear(); return true; } void start(){ cout<<endl<<endl; cout<<" "<<" * * * * * * * * "<<endl; cout<<" "<<" * * * * * * "<<endl; cout<<" "<<" * * * * * * "<<endl; cout<<" "<<" * * * * * * * *"<<endl; cout<<" "<<" * "<<endl; cout<<" "<<" "; } int lines(){ int i=0; string line; fstream file; file.open("quests.txt",ios::in); while(getline(file,line)) i++; file.close(); file.clear(); return i; } bool questions(int HowM,string *qu){ fstream file; string line; bool status=true; file.open("quests.txt",ios::in); if(file.good()== false) status=false; while(getline(file,line)){ *qu=line; qu++; } file.close(); file.clear(); return status; }
#include <iostream> #include <windows.h> #include <conio.h> #include <cstdlib> #include <fstream> #include <string> #include <math.h> #include <algorithm> using namespace std; bool check(string pyt,string odp,string Modp){ system("cls"); cout<<"Czy twoja odpowiedz jest dobra?"<<endl; cout<<"oryginalna odpowiedz to: "<<odp<<"a ty odpowiedziales: "<<Modp; cout<<" Y\N"; if((getch()=='Y')||(getch()=='y')) return true; else return false; } bool do_quest(int quest,int id,bool mark_check,string *quests){ id=1; string pyt="brak",odp="brak",M_odp="brak"; if(id==0) { quests+=quest*2; pyt=*quests; quests+=1; odp=*quests; }else{ quests+=quest*2; odp=*quests; quests+=1; pyt=*quests; } //cout<<endl<<endl<<"pytanie: "<<pyt<<endl<<"odpowiedz: "<<odp<<endl<<endl; cout<<"pytanie: "<<pyt<<endl<<"odpowiedz: "; getline( cin, M_odp); if(mark_check==false) return (check(pyt,odp,M_odp)); if(odp==M_odp) {cout<<endl<<" Dobze"; return true;} system("cls"); cout<<"poprawna odpowiedz to: "<<endl<<pyt<<"<----->"<<odp; return false; }
#include <iostream> #include <windows.h> #include <conio.h> #include <cstdlib> #include <fstream> #include <string> #include <math.h> #include <algorithm> #include <time.h> using namespace std; int random(int HM,int last){ int x; for(;;){ x=rand()%HM; if(last==x) {}else break; } return x; }
HCL kwas chlorowodorowy H2S kwas siarkowodorowy HBr kwas bromowodorowy HF kwas fluorowodorowy HI kwas jodowodorowy H2SO3 kwas siarkowy IV H2SO4 kwas siarkowy VI HNO3 kwas azotowy V HNO2 kwas azotowy III H3BO3 kwas borowy H3PO4 kwas fosforowy V H3PO3 kwas fosforowy III H2SiO3 kwas krzemowy IV HClO3 kwas chlorowy V
93,605 zapytań
142,530 odpowiedzi
322,999 komentarzy
63,095 pasjonatów
Motyw:
Pajacyk od wielu lat dożywia dzieci. Pomóż klikając w zielony brzuszek na stronie. Dziękujemy! ♡
Oto polecana książka warta uwagi.Pełną listę książek znajdziesz tutaj