Aliendreamer

magicnumbers

Mar 18th, 2017
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.17 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace issue6magicnumbers2
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.  
  14.             int start = int.Parse(Console.ReadLine());
  15.             int end = int.Parse(Console.ReadLine());
  16.             int magicnumber = int.Parse(Console.ReadLine());
  17.  
  18.  
  19.             int combination = 0;
  20.             int count = 0;
  21.             int countotal = count;
  22.            
  23.             for ( int i=start;i<=end;i++)
  24.             {
  25.                 for( int j=start;j<=end;j++)
  26.                 {
  27.                        
  28.                     combination = i + j;
  29.                     count+=1;
  30.  
  31.                     if (combination == magicnumber)
  32.                     {
  33.                         Console.WriteLine("{0} {1}+{2}={3}", countotal, start, end, magicnumber);
  34.  
  35.                     }
  36.                     else
  37.                     {
  38.                         Console.WriteLine("{0} {1}", countotal, magicnumber);
  39.  
  40.                     }
  41.  
  42.  
  43.  
  44.                 }
  45.  
  46.             }
  47.              
  48.            
  49.  
  50.  
  51.  
  52.         }
  53.     }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment