Name of problem:
Solution:
using System;
namespace add_numers
{
class Program
{
static void Main(string[] args)
{
int i, j, k, l, m, n;
float sum;
i = Convert.ToInt32(Console.ReadLine());
j = Convert.ToInt32(Console.ReadLine());
k = Convert.ToInt32(Console.ReadLine());
l = Convert.ToInt32(Console.ReadLine());
m = Convert.ToInt32(Console.ReadLine());
n = Convert.ToInt32(Console.ReadLine());
sum = i + j + k + l + m - n;
Console.WriteLine(i + "+" + j + "+" + k + "+" + l + "+" + m + "-" + n + "="+ sum);
Console.ReadKey();
}
}
}
- Write a program that outputs all possibilities to put
+
or-
or nothing between the numbers 1,2,…,9 (in this order) such that the result is 100. For example 1 + 2 + 3 - 4 + 5 + 6 + 78 + 9 = 100.
Solution:
using System;
namespace add_numers
{
class Program
{
static void Main(string[] args)
{
int i, j, k, l, m, n;
float sum;
i = Convert.ToInt32(Console.ReadLine());
j = Convert.ToInt32(Console.ReadLine());
k = Convert.ToInt32(Console.ReadLine());
l = Convert.ToInt32(Console.ReadLine());
m = Convert.ToInt32(Console.ReadLine());
n = Convert.ToInt32(Console.ReadLine());
sum = i + j + k + l + m - n;
Console.WriteLine(i + "+" + j + "+" + k + "+" + l + "+" + m + "-" + n + "="+ sum);
Console.ReadKey();
}
}
}
No comments:
Post a Comment