Advertisement
Aslai

Untitled

Feb 18th, 2012
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace PuzzleSolver{
  7.     class program{
  8.         struct t{
  9.             public int carry, times;
  10.             public t( int c, int t ){
  11.                 carry = c; times = t;
  12.             }
  13.         };
  14.         static void Main( string[] args ){
  15.             t[] list = { new t(0,0), new t(20,3), new t(40,6), new t(60,9), new t(10,2), new t(30,5), new t(50,8), new t(0,1), new t(20,4), new t(40,7) };
  16.             Console.Write("Target: ");
  17.             String inp = Console.ReadLine();
  18.             int target = Convert.ToInt32( inp );
  19.             int j, i;
  20.             int[] save = new int[4];
  21.             for( i = 3; i >= 0; --i ){
  22.                 j = target - target / 10 * 10;
  23.                 save[i] = list[j].times;
  24.                 target = ( target - list[j].carry ) / 10;
  25.             }
  26.             for( i = 0; i < 4; ++i )
  27.                 Console.Write("{0}{1}", save[i], i < 3 ? '>' : ' ' );
  28.             Console.ReadLine();
  29.         }
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement