Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int sumAdj(int [][201], int, int);
- int main(){
- int x, i;
- int arr[201][201]={{0}};
- int success=0, count=1;
- arr[100][100]=1;
- for(x=1; x<100 && !success; x++){
- for(i=0; i<x*2 && !success; i++){
- arr[100+x-1-i][100+x]=sumAdj(arr, 100+x-1-i, 100+x);
- success = (arr[100+x-1-i][100+x]> 312051);
- count++;
- printf("%d\n", arr[100+x-1-i][100+x]);
- }
- for(i=0; i<x*2 && !success ; i++){
- arr[100-x][100+x-i-1] = sumAdj(arr, 100-x, 100+x-i-1);
- success = (arr[100-x][100+x-i-1] >312051);
- count++;
- printf("%d\n", arr[100-x][100+x-i-1]);
- }
- for(i=0; i<x*2 && !success; i++){
- arr[100-x+i+1][100-x]=sumAdj(arr, 100-x+i+1, 100-x);
- success = (arr[100-x+i+1][100-x] >312051);
- count++;
- printf("%d\n", arr[100-x+i+1][100-x]);
- }
- for(i=0; i<x*2 &&!success; i++){
- arr[100+x][100-x+1+i] = sumAdj(arr, 100+x, 100-x+1+i);
- success = (arr[100+x][100-x+1+i] >312051);
- count++;
- printf("%d\n", arr[100+x][100-x+1+i]);
- }
- }
- printf("count : %d, succ: %d\n", count, success);
- return 0;
- }
- int sumAdj(int arr[][201], int i, int j){
- printf("%d %d %d\n%d %d %d\n%d %d %d\n", arr[i-1][j-1], arr[i-1][j], arr[i-1][j+1],
- arr[i][j-1], arr[i][j], arr[i][j+1],
- arr[i+1][j-1], arr[i+1][j], arr[i+1][j+1]);
- return arr[i+1][j] + arr[i-1][j] +arr[i+1][j+1]+arr[i+1][j-1]
- +arr[i][j+1]+arr[i][j-1] +arr[i-1][j-1]+arr[i-1][j+1];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement