You may make 2d array representing 3 poles.
Get input from user and initialize
arr[2][number] = {0};
for(i=0; i<number; i++){
arr[0][i] = number-i;
}
And start a loop which helps user to input 2 numbers and operate moving.
You need to check several conditions like
- if k > l, arr[x][k] < arr[x][l] where x, k, l is proper number
- if input is not proper number (like ur example)
Maybe code can be like below.
scanf("%d %d", &n1, &n2);
while(n1<3 && n1>=0 && n2 <= number &&n2 > 0){
/// deleteDisk: find last component which is not zero and make it zero and return deleted disk size
disk = deleteDisk(arr, n1);
/// addDisk: change first zero to disk, return 0 if violates condition 1
err = addDisk(arr, n2, disk);
if (err == 0)
break;
/// arrayPrint: print 2d array til zero
arrayPrint;
scanf("%d %d", &n1, &n2);
}
solved Tower of Hanoi – User is moving disks (c)