Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
C++ code to count volume of given text
Suppose we have a string S with n characters. S is a single-space separated words, consisting of small and capital English letters. Volume of the word is number of capital letters in the given word. And volume of the text is maximum volume of all words in the text. We have to find the volume of the given text.
So, if the input is like S = "Paper MILL", then the output will be 4, because volume of first word is 1 and second word is 4, so maximum is 4.
Steps
To solve this, we will follow these steps −
ans := 0 a := 0 n := size of S for initialize i := 0, when i = 'A' and sExample
Let us see the following implementation to get better understanding −
#includeusing namespace std; int solve(string S){ int ans = 0, a = 0; int n = S.size(); for (int i = 0; i = 'A') && (s Input
"Paper MILL"Output
4
Advertisements
