Unknown number of inputs

In some problems like the Bytelandian gold coins problem , the input specifies that there will be several test cases(upto 10). In such cases, how to terminate the code after the unknown number of inputs are entered in c++.

use while(scanf("%d", &n)==1)

//