Skip to content

Instantly share code, notes, and snippets.

@Zemaaan
Last active May 2, 2018 10:38
Show Gist options
  • Save Zemaaan/42ac502d97a42a88bab4c9fab1966719 to your computer and use it in GitHub Desktop.
Save Zemaaan/42ac502d97a42a88bab4c9fab1966719 to your computer and use it in GitHub Desktop.
Programiranje vjezbe 2.5.2018 - 1. zadatak
// ConsoleApplication1.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;
// funkcija koja ime onoliko puta koliki je broj slova.
//void ispis_imena(string ime) {
// for (int pozicija = 0; pozicija < ime.length(); pozicija++)
// cout << ime << endl;
//}
int broj_slova(string ime) {
int brojac_slova_a = 0;
for (int pozicija = 0; pozicija < ime.length(); pozicija++) {
if (ime[pozicija] == 'A' or ime[pozicija] == 'a') {
brojac_slova_a++;
}
}
return brojac_slova_a;
}
int main()
{
string rijec;
cout << "Upisi ime: " << endl;
cin >> rijec;
//ispis_imena(rijec);
if (broj_slova(rijec) == 0) {
cout << "Rijec " << rijec << " ne sadrzi " << "slovo a." << endl;
system("pause");
return 0;}
cout << "Rijec " << rijec << " sadrzi " << broj_slova(rijec) << " slova a." << endl;
system("pause");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment