// Write a template function I N P U T. It requires the user to enter a non-negative number and verifies that the number entered by the user is
// No is equal to or greater than 0. If not, it indicates that the input is invalid and you need to enter a new number. When the function is not
// You should be given three chances before exiting successfully. If the input is successful, the function should return the number as a reference parameter.
// If the input is successful, the function returns true; otherwise, f a l s e is returned. Test the function on the computer.
# Include <stdio. h>
Template <class T>
Bool input (T &)
{
If (A <0)
{
Printf ("invalid input! /N ");
Return false;
}
Else
{
Printf ("right input! /N ");
Return true;
}
}
Void main ()
{
Int iinput, I = 0;
Printf ("Please input an nonnegative number :");
Scanf ("% F", & iinput );
I ++;
While (! Input (iinput ))
{
If (I> = 3)
{
Printf ("You have tried for three times, now you shoshould exit! /N ");
Break;
}
Printf ("Please input again :");
Scanf ("% F", & iinput );
I ++;
}
}