SHARE
TWEET

Untitled

a guest Oct 23rd, 2019 82 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4. #include <iostream>
  5.  
  6. int Mining(int* Miner, int Dimension, int** Mine)
  7. {
  8.     int Score = *Miner;
  9.    
  10.  
  11.     for (int i = 1; i < Dimension; i++)
  12.     {
  13.         int BestMove = 0;
  14.  
  15.         for (int j = 0; j < Dimension; j++)
  16.         {
  17.             int Top = Mine[i+1][j-1];
  18.             int Middle = Mine[i + 1][j];
  19.             int Bottom = Mine[i + 1][j + 1];
  20.  
  21.             if(BestMove<Top)
  22.             {
  23.                 BestMove = Top;
  24.             }
  25.  
  26.             if (BestMove < Middle)
  27.             {
  28.                 BestMove = Middle;
  29.             }
  30.  
  31.             if (BestMove < Bottom)
  32.             {
  33.                 BestMove = Bottom;
  34.             }
  35.  
  36.             Score += BestMove;
  37.         }
  38.     }
  39.  
  40.     printf("%d", Score);
  41.     return Score;
  42. }
  43.  
  44. int main()
  45. {
  46.     //Variables
  47.     int Normal = 2;
  48.     int Dimension = 1;
  49.  
  50.     int MostDiamonds = 0;
  51.     int* Miner=0;
  52.  
  53.     int Score;
  54.  
  55.     //Check
  56.     do {
  57.  
  58.     scanf_s("%d", &Dimension);
  59.  
  60.     } while (1 >= Dimension >= 100);
  61.  
  62.     int** Mine=(int**)malloc(Dimension * sizeof(int));;
  63.  
  64.     //Array Allocation
  65.     for (int i = 0; i < Dimension; i++)
  66.     {
  67.         Mine[i] = (int*)malloc(Dimension * sizeof(int));
  68.     }
  69.  
  70.     //Fill Up
  71.     for (int i = 0; i < Dimension; i++)
  72.     {
  73.         for (int j = 0; j < Dimension; j++)
  74.         {
  75.             int m=0;
  76.             scanf_s("%d", &m);
  77.             Mine[i][j] = m;
  78.         }
  79.     }
  80.  
  81.     //Printing the results
  82.     for (int i = 0; i < Dimension; i++)
  83.     {
  84.         for (int j = 0; j < Dimension; j++)
  85.         {
  86.             printf("%d", Mine[i][j]);
  87.         }
  88.     }
  89.    
  90.  
  91.     //Starting point
  92.     for (int i = 0; i < Dimension; i++)
  93.     {
  94.        
  95.         if (MostDiamonds < (int)Mine[0][i])
  96.         {
  97.             MostDiamonds = Mine[0][i];
  98.  
  99.         }
  100.  
  101.         if (MostDiamonds == Mine[0][i])
  102.         {
  103.             Miner = &Mine[0][i];
  104.         }
  105.     }
  106.  
  107.     printf("\n%p", Miner);
  108.     printf("\n%i", *Miner);
  109.    
  110.     Score = Mining(Miner, Dimension, Mine);
  111.  
  112.     printf("\n%d", Score);
  113.  
  114.     return 0;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top