Skip to content

Instantly share code, notes, and snippets.

@Zemaaan
Last active April 25, 2018 11:10
Show Gist options
  • Save Zemaaan/0715e651ea59cf120ba60d631ab26979 to your computer and use it in GitHub Desktop.
Save Zemaaan/0715e651ea59cf120ba60d631ab26979 to your computer and use it in GitHub Desktop.
// ConsoleApplication1.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <string>;
using namespace std;
int main()
{
string recenica;
int brojac_rijeci = 0;
cout << "Upisi recenicu: ";
cin >> recenica;
for (int pozicija = 0; pozicija < recenica.length() - 1; pozicija++) {
if (recenica[pozicija] == ' ') {
brojac_rijeci++;
}
}
brojac_rijeci++;
cout << "Recenica ima: " << brojac_rijeci << " rijeci." << endl;
system("pause");
return 0;
}
// ConsoleApplication1.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <string>;
using namespace std;
int main()
{
string recenica;
int brojac_rijeci = 0;
cout << "Upisi recenicu: ";
getline(recenica);
for (int pozicija = 0; pozicija < recenica.length() - 1; pozicija++) {
if (recenica[pozicija] == ' ') {
brojac_rijeci++;
}
}
brojac_rijeci++;
cout << "Recenica ima: " << brojac_rijeci << " rijeci." << endl;
system("pause");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment