c++ - count specific number of elements -


for example, if have array of 5 inputted elements, how count how many times specific value entered if value has been established in variable.

input: 4 4 4 1 2 

if click defined 4 how count how many times click used in array? makes sense. thanks

this how c style arrays.

int i; int count = 0; for(i = 0; < arraysize; ++i) {     if(array[i] == click)         ++count; } 

arraysize size of statically allocated array, array array variable , click value looking for. in count count of variable saved.


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -