[ create a new paste ] login | about

Link: http://codepad.org/Y31Tv06I    [ raw code | output | fork ]

C, pasted on Feb 8:
#include<stdio.h>
int move(int,int,int,int,int,int,int,int,int,int,int,int);
int kui1(int,int,int,int,int,int,int,int,int,int,int,int);
int kui2(int,int,int,int,int,int,int,int,int,int,int,int);
int kui3(int,int,int,int,int,int,int,int,int,int,int,int);


int main(){
	int hanoi[300]={0},d=0,e=100,f=200,n=0,m=100,l=200,s=0,v=0,w=0,z=0,lena=0,lenb=0,lenc=0,lend=0;
	scanf("%d",&w);
	for(w,v; w >= 1; w--, v++)
		hanoi[v] = w;
	n = v;
	lena = v + 1;
	while(hanoi[200+v] != 1)
		kui1(d,e,f,n,m,l,z,lena,lenb,lenc,lend,hanoi[300]);
	return 0;
}

int move(int d,int e,int f,int n,int m,int l,int z,int lena,int lenb,int lenc,int lend,int hanoi[300]){
	if(hanoi[z] == 0 || hanoi[n] < hanoi[m] || hanoi[n] < hanoi[l]){
		hanoi[z] = hanoi[n];
		printf("%d %d %d\n",hanoi[n],(n / 100) + 1,(z / 100) + 1);
		lena--;
		hanoi[n] = 0;
		if(z < 200){
			m++;
			lenb++;
		}
		else{
			l++;
			lenc++;
		}
		n--;
	}
	else if(hanoi[100] > hanoi[200]){
		if((lena % 2) == 0)
			kui2(d,e,f,n,m,l,z,lena,lenb,lenc,lend,hanoi[300]);
		else
			kui3(d,e,f,n,m,l,z,lena,lenb,lenc,lend,hanoi[300]);
	}
	else{
		if((lena % 2) == 0)
			kui2(d,e,f,n,m,l,z,lena,lenb,lenc,lend,hanoi[300]);
		else
			kui3(d,e,f,n,m,l,z,lena,lenb,lenc,lend,hanoi[300]);
	}
	return 0;
}



int kui1(int d,int e,int f,int n,int m,int l,int z,int lena,int lenb,int lenc,int lend,int hanoi[300]){
	while(hanoi[d] != 0){
		if((lena % 2) == 0)
			move(d,e,f,n,m,l,m,lena,lenb,lenc,lend,hanoi[300]);
		else
			move(d,e,f,n,m,l,l,lena,lenb,lenc,lend,hanoi[300]);
	}
	if(hanoi[e] == 0)
		return 0;
	else{
		while(hanoi[e] != 0){
			kui2(d,e,f,n,m,l,z,lena,lenb,lenc,lend,hanoi[300]);
		}
	}
	return 0;
}


int kui2(int d,int e,int f,int n,int m,int l,int z,int lena,int lenb,int lenc,int lend,int hanoi[300]){
	for(lenb;lenb > 0;lenb--){
		if((lenb % 2) == 0){
			n++;
			move(d,e,f,n,m,l,e,lena,lenb,lenc,lend,hanoi[300]);
		}
		else{
			l++;
			move(d,e,f,n,m,l,e,lena,lenb,lenc,lend,hanoi[300]);
		}
	}
	return 0;
}


int kui3(int d,int e,int f,int n,int m,int l,int z,int lena,int lenb,int lenc,int lend,int hanoi[300]){
	for(lenc;lenc > 0;lenc--){
		if((lenc % 2) == 0){
			n++;
			move(d,e,f,n,m,l,e,lena,lenb,lenc,lend,hanoi[300]);
		}
		else{
			m++;
			hanoi[m] = hanoi[l];
			l--;
			lenb++;
			lenc--;
			move(d,e,f,n,m,l,f,lena,lenb,lenc,lend,hanoi[300]);
	}
	return 0;
}


Output:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Line 20: error: conflicting types for 'move'
Line 2: error: previous declaration of 'move' was here
Line 53: error: conflicting types for 'kui1'
Line 3: error: previous declaration of 'kui1' was here
In function 'kui1':
Line 56: warning: passing argument 12 of 'move' makes pointer from integer without a cast
Line 58: warning: passing argument 12 of 'move' makes pointer from integer without a cast
t.c: At top level:
Line 71: error: conflicting types for 'kui2'
Line 4: error: previous declaration of 'kui2' was here
In function 'kui2':
Line 75: warning: passing argument 12 of 'move' makes pointer from integer without a cast
Line 79: warning: passing argument 12 of 'move' makes pointer from integer without a cast
t.c: At top level:
Line 86: error: conflicting types for 'kui3'
Line 5: error: previous declaration of 'kui3' was here
In function 'kui3':
Line 90: warning: passing argument 12 of 'move' makes pointer from integer without a cast
Line 98: warning: passing argument 12 of 'move' makes pointer from integer without a cast
Line 101: error: expected declaration or statement at end of input


Create a new paste based on this one


Comments: