Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <stdlib.h>
- #include <windows.h>
- #include <iostream>
- #include <fstream>
- #include <vector>
- #include <string>
- #include <cstdlib>
- #include <cmath>
- #include <conio.h>
- #include <time.h>
- #include <sstream>
- #include <MMSystem.h> // Fyrir multi media stuðning
- using namespace std;
- int main()
- {
- srand(time(NULL));
- system("chcp 1252>nul"); // isl stafir
- cout << "Fýlukallinn" << endl; // titill á leik
- // PlaySound(TEXT("game.wav"), NULL, SND_SYNC); /* lærði af youtube þurfti að bæta við input i propertys
- // spilar hljóð*/
- string valk;//upphafsval
- cout << "SHALL WE PLAY A GAME?" << endl; // texti ef ekkert audio
- cout << "Veldu Y/N (Yes/No)" << endl; //valkostir
- cout << ">>";
- cin >> valk;
- if (valk =="y")
- {
- ifstream txt("ordaskra.txt");
- string myArray[50];
- if (txt.is_open())
- {
- for (int i = 1; i < 20; ++i) // les úr orðaskrá inn í array
- {
- txt >> myArray[i];
- }
- }
- for (int j = 1; j < 20; j++) // velur random stað í array og prentar út
- {
- j = rand() % 19 + 1;
- string f = myArray[j];
- int count = 0;
- char checkstafur;
- cout << f << endl;
- cout << "Það eru " << f.size() << " stafir í orðinu" << "\n";
- cout << "giskaðu á staf";
- cin >> checkstafur;
- cout << "það eru " << count << "af" << checkstafur << "í orðinu\n";
- for (int i = 0; i < f.size(); i++)
- {
- if (f[i] == checkstafur)
- {
- ++count;
- }
- }
- system("pause");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement