Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- using System.Data;
- using System.Text;
- namespace NumSequenceCalculator
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.WriteLine("This app calculates a sequence of numbers from 1 to n. n must NOT be bigger" +
- " than 9. The app works until the command END.");
- Console.Write("Enter a formula with argument n. For example: a=n+1 ");
- var inputFormula = Console.ReadLine().Split('=');
- Console.Write("Calculate for n= ");
- int k = int.Parse(Console.ReadLine());
- char counter = '1';
- while (inputFormula[1] != "END")
- {
- while (int.Parse(counter.ToString()) != k+1)
- {
- List<char> charList = inputFormula[1].ToList();
- for (int i = 0; i < charList.Count; i++)
- {
- if (charList[i] == 'n')
- {
- charList[i] = counter;
- }
- //!
- }
- counter++;
- var foo = new string(charList.ToArray());
- var sb = new StringBuilder();
- var dt = new DataTable();
- sb.Append(foo).Append(" = ").Append(dt.Compute(foo, ""));
- Console.WriteLine(sb.ToString());
- }
- inputFormula = Console.ReadLine().Split('=');
- k = int.Parse(Console.ReadLine());
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement