Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pch.h";
- #include <iostream>
- using namespace std;
- int main()
- {
- char tekst[100];
- cout << "Podaj tekst do policzenia znakow i wyrazow: ";
- cin.get(tekst, 100); // limit 100 znakow
- int znaki = 0;
- int wyrazy = 0;
- int czySpacja = true;
- for (int i = 0; i < strlen(tekst); ++i) {
- if (isspace(tekst[i])) {
- czySpacja = true;
- }
- else
- {
- if (czySpacja) {
- wyrazy++;
- }
- czySpacja = false;
- znaki++;
- }
- }
- cout << "Statystyki podanego tekstu: znaki: " << znaki << ", wyrazy: " << wyrazy << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement