Skip to content

Instantly share code, notes, and snippets.

@Zemaaan
Created May 2, 2018 10:49
Show Gist options
  • Save Zemaaan/116249110617bc0de6a745af0bd116d4 to your computer and use it in GitHub Desktop.
Save Zemaaan/116249110617bc0de6a745af0bd116d4 to your computer and use it in GitHub Desktop.
Programiranje vjezbe 2.5.2018 - 3. zadatak
// ConsoleApplication1.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;
bool sadrzi_slovo(string rijec, char slovo) {
for (int pozicija = 0; pozicija < rijec.length(); pozicija++) {
if (rijec[pozicija] == slovo) {
return true;
}
}
}
int main()
{
string rijec;
char slovo;
cout << "Upisi rijec: " << endl;
cin >> rijec;
cout << "Upisi slovo koje se trazi: " << endl;
cin >> slovo;
if (sadrzi_slovo(rijec, slovo) == true) {
cout << "Rijec " << rijec << " sadrzi slovo " << slovo << "."<< endl;}
else{ cout << "Rijec " << rijec << " ne sadrzi slovo " << slovo << "." << endl; }
system("pause");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment