So now just add in a counter.
Why are you using such a stupid function? It's just:
Code:void f(int a) { return a >= 1 ? 1 : a; }
So now just add in a counter.
Why are you using such a stupid function? It's just:
Code:void f(int a) { return a >= 1 ? 1 : a; }
Last edited by john.c; 02-03-2024 at 09:54 AM.
A little inaccuracy saves tons of explanation. - H.H. Munro
How to add counters
Code:int divide(int a) { numcalls++; if (a > 1) { return divide (a/2); } return a; } int divide(int a) { for( ; a > 1 ; a /=2 ) { numloops++; } return a; }
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.