i have a string like this :
s=2+4
(s[0]=2,s[1]=+,s[2]=4).
how can i extract 2, 4 from it ?
using System;
class program
{
public static void Main()
{
int n,x=0,y=0,a,a1,b1,b,f=0,z,sum=0,q=0,l=0;
char c;
string s,s1,s2,s3;
int [] sum1=new int [4];
Console.WriteLine("Let's go :");
s = Console.ReadLine();
for (int i=0;i<s.length;i++)>
{
switch( s[i])
{
case '0':
n = Convert.ToInt32(s[q]);
string[,] zero = new string[7, 3] { { "0", "0", "0" }, { "0", " ", "0" }, { "0", " ", "0" }, { "0", " ", "0" }, { "0", " ", "0" }, { "0", "0", "0" }, { "0", "0", "0" } };
for (int h=0;h<7;h++)
{
for (int j=0;j<3;j++)
{
Console.Write(zero[h,j]);
}
Console.WriteLine();
}
sum1[q]=n;
q = q + 1;
break;
case '1':
n = Convert.ToInt32(s[i]);
string [,] one=new string[7,3] {{"1","1","1"},{" " ," ","1"},{" "," ","1"},{" "," ","1"},{" "," ","1"},{" "," ","1"},{" "," ","1"}};
for (int h = 0; h < 7; h++)
{
for (int j = 0; j < 3; j++)
{
Console.Write(one[h, j]);
}
Console.WriteLine();
}
sum1[q]=n;
q = q + 1;
break;
case '2':
n = Convert.ToInt32(s[i]);
string[,] two= new string[7, 3] { { "2","2","2" }, { " "," ","2" }, { " "," ","2" }, { "2","2","2" }, { "2"," "," " }, { "2"," "," " }, {"2","2","2" } };
for (int h = 0; h < 7; h++)
{
for (int j = 0; j < 3; j++)
{
Console.Write(two[h, j]);
}
Console.WriteLine();
}
x = 2;
sum1[q]=n;
q = q + 1;
break;
case '3':
n = Convert.ToInt32(s[i]);
string[,] three = new string[7, 3] { {"3","3","3" }, { " ", " ", "3" }, { " "," ","3" }, { "3","3","3" }, { " "," ","3" }, { " "," ","3" }, {"3","3","3" } };
for (int h = 0; h < 7; h++)
{
for (int j = 0; j < 3; j++)
{
Console.Write(three[h, j]);
}
Console.WriteLine();
}
y = 3;
sum1[q]=n;
q = q + 1;
break;
case '4':
n = Convert.ToInt32(s[i]);
string[,] four = new string[7, 3] { { "4"," ","4" }, {"4"," ","4"}, {"4"," ","4" }, { "4","4","4"}, { " "," ","4"}, { " ", " ","4"}, { " "," ","4"} };
for (int h = 0; h < 7; h++)
{
for (int j = 0; j < 3; j++)
{
Console.Write(four[h, j]);
}
Console.WriteLine();
}
x = 4;
sum1[q]=n;
q = q + 1;
break;
case '5':
n = Convert.ToInt32(s[i]);
string[,] five = new string[7, 3] { { "5","5","5" }, {"5"," "," " }, {"5"," "," " }, { "5","5","5" }, { " "," ", "5" }, { " ", " ", "5" }, { "5","5","5" } };
for (int h = 0; h < 7; h++)
{
for (int j = 0; j < 3; j++)
{
Console.Write(five[h, j]);
}
Console.WriteLine();
}
y = 5;
sum1[q]=n;
q = q + 1;
break;
case '6':
n = Convert.ToInt32(s[i]);
string[,] six = new string[7, 3] { { "6","6","6" }, {"6", " "," " }, {"6", " ", " " }, {"6","6","6" }, {"6"," ","6"}, {"6"," ","6" }, {"6","6","6" } };
for (int h = 0; h < 7; h++)
{
for (int j = 0; j < 3; j++)
{
Console.Write(six[h, j]);
}
Console.WriteLine();
}
x = 6;
sum1[q]=n;
q = q + 1;
break;
case '7':
n = Convert.ToInt32(s[i]);
string[,] seven = new string[7,4] { { "7","7","7"," " }, { " ", " ", "7"," " }, { " ", " ", "7" ," "}, { " "," ","7"," " }, { "7","7","7","7" }, { " ", " ", "7"," " }, { " ", " ","7"," " } };
for (int h = 0; h < 7; h++)
{
for (int j = 0; j < 4; j++)
{
Console.Write(seven[h, j]);
}
Console.WriteLine();
}
y = 7;
sum1[q]=n;
q = q + 1;
break;
case '8':
n = Convert.ToInt32(s[i]);
string[,] eight = new string [7,3 ] { {"8","8","8" }, {"8"," ","8" }, { "8"," ","8" }, { "8","8","8" }, { "8"," ","8" }, { "8"," ","8" }, {"8","8","8"} };
for (int h = 0; h < 7; h++)
{
for (int j = 0; j < 3; j++)
{
Console.Write(eight[h, j]);
}
Console.WriteLine();
}
x = 8;
sum1[q]=n;
q = q + 1;
break;
case '9':
n = Convert.ToInt32(s[i]);
string[,] nine = new string[7, 3] { {"9","9","9" }, {"9"," ","9" }, {"9"," ","9" }, {"9","9","9"}, {" "," ","9"}, {" "," ","9" }, {"9","9","9"} };
for (int h = 0; h < 7; h++)
{
for (int j = 0; j < 3; j++)
{
Console.Write(nine[h, j]);
}
Console.WriteLine();
}
y = 9;
sum1[q]=n;
q = q + 1;
break;
case '+':
string[,] plus = new string [3,3] {{" " ,"+"," " },{"+" ,"+","+"},{" ","+"," "}};
for (int h = 0; h < 3; h++)
{
for (int j = 0; j < 3; j++)
{
Console.Write(plus[h, j]);
}
Console.WriteLine();
}
break;
case '-':
string[,] min = new string[3, 3] { { " ", " ", " " }, { "-", "-", "-" }, { " ", " ", " " } };
for (int h = 0; h < 3; h++)
{
for (int j = 0; j < 3; j++)
{
Console.Write(min[h, j]);
}
Console.WriteLine();
c = '-';
}
break;
case '*':
string[,] mul = new string[3, 3] { { "*", " ", "*" }, { " ", "*", " " }, { "*", " ", "*" } };
for (int h = 0; h < 3; h++)
{
for (int j = 0; j < 3; j++)
{
Console.Write(mul[h, j]);
}
Console.WriteLine();
}
break;
case '/':
string[,] div = new string[3, 3] { { " ", " ", "/" }, { " ", "/", " " }, { "/", " ", " " } };
for (int h = 0; h < 3; h++)
{
for (int j = 0; j < 3; j++)
{
Console.Write(div[h, j]);
}
Console.WriteLine();
}
break;
default :
break;
}
}
string[,] equel = new string[3, 3] { { "=", "=", "= " }, { " ", " ", " " }, { "=", "=", "=" } };
for (int h = 0; h < 3; h++)
{
for (int j = 0; j < 3; j++)
{
Console.Write(equel[h, j]);
}
Console.WriteLine();
}
switch(s[1])
{
case'+':
f = a+b;
break;
case'-':
f = a - b;
break;
case'*':
f = a * b;
break;
case'/':
f = a / b;
break;
}
switch(f)
{
case 0:
string[,] zero = new string[7, 3] { { "0", "0", "0" }, { "0", " ", "0" }, { "0", " ", "0" }, { "0", " ", "0" }, { "0", " ", "0" }, { "0", "0", "0" }, { "0", "0", "0" } };
for (int h = 0; h < 7; h++)
{
for (int j = 0; j < 3; j++)
{
Console.Write(zero[h, j]);
}
Console.WriteLine();
}
break;
case 1:
string[,] one = new string[7, 3] { { "1", "1", "1" }, { " ", " ", "1" }, { " ", " ", "1" }, { " ", " ", "1" }, { " ", " ", "1" }, { " ", " ", "1" }, { " ", " ", "1" } };
for (int h = 0; h < 7; h++)
{
for (int j = 0; j < 3; j++)
{
Console.Write(one[h, j]);
}
Console.WriteLine();
}
break;
case 2:
string[,] two = new string[7, 3] { { "2", "2", "2" }, { " ", " ", "2" }, { " ", " ", "2" }, { "2", "2", "2" }, { "2", " ", " " }, { "2", " ", " " }, { "2", "2", "2" } };
for (int h = 0; h < 7; h++)
{
for (int j = 0; j < 3; j++)
{
Console.Write(two[h, j]);
}
Console.WriteLine();
}
break;
case 3:
string[,] three = new string[7, 3] { { "3", "3", "3" }, { " ", " ", "3" }, { " ", " ", "3" }, { "3", "3", "3" }, { " ", " ", "3" }, { " ", " ", "3" }, { "3", "3", "3" } };
for (int h = 0; h < 7; h++)
{
for (int j = 0; j < 3; j++)
{
Console.Write(three[h, j]);
}
Console.WriteLine();
}
break;
case 4:
string[,] four = new string[7, 3] { { "4", " ", "4" }, { "4", " ", "4" }, { "4", " ", "4" }, { "4", "4", "4" }, { " ", " ", "4" }, { " ", " ", "4" }, { " ", " ", "4" } };
for (int h = 0; h < 7; h++)
{
for (int j = 0; j < 3; j++)
{
Console.Write(four[h, j]);
}
Console.WriteLine();
}
break;
case 5:
string[,] five = new string[7, 3] { { "5", "5", "5" }, { "5", " ", " " }, { "5", " ", " " }, { "5", "5", "5" }, { " ", " ", "5" }, { " ", " ", "5" }, { "5", "5", "5" } };
for (int h = 0; h < 7; h++)
{
for (int j = 0; j < 3; j++)
{
Console.Write(five[h, j]);
}
Console.WriteLine();
}
break;
case 6:
string[,] six = new string[7, 3] { { "6", "6", "6" }, { "6", " ", " " }, { "6", " ", " " }, { "6", "6", "6" }, { "6", " ", "6" }, { "6", " ", "6" }, { "6", "6", "6" } };
for (int h = 0; h < 7; h++)
{
for (int j = 0; j < 3; j++)
{
Console.Write(six[h, j]);
}
Console.WriteLine();
}
break;
case 7:
string[,] seven = new string[7, 4] { { "7", "7", "7", " " }, { " ", " ", "7", " " }, { " ", " ", "7", " " }, { " ", " ", "7", " " }, { "7", "7", "7", "7" }, { " ", " ", "7", " " }, { " ", " ", "7", " " } };
for (int h = 0; h < 7; h++)
{
for (int j = 0; j < 4; j++)
{
Console.Write(seven[h, j]);
}
Console.WriteLine();
}
break;
case 8:
string[,] eight = new string[7, 3] { { "8", "8", "8" }, { "8", " ", "8" }, { "8", " ", "8" }, { "8", "8", "8" }, { "8", " ", "8" }, { "8", " ", "8" }, { "8", "8", "8" } };
for (int h = 0; h < 7; h++)
{
for (int j = 0; j < 3; j++)
{
Console.Write(eight[h, j]);
}
Console.WriteLine();
}
break;
case 9:
string[,] nine = new string[7, 3] { { "9", "9", "9" }, { "9", " ", "9" }, { "9", " ", "9" }, { "9", "9", "9" }, { " ", " ", "9" }, { " ", " ", "9" }, { "9", "9", "9" } };
for (int h = 0; h < 7; h++)
{
for (int j = 0; j < 3; j++)
{
Console.Write(nine[h, j]);
}
Console.WriteLine();
}
break;
}
Console.ReadKey();
}
}