Click here to Skip to main content
15,909,939 members
Home / Discussions / C#
   

C#

 
GeneralRe: c# Brain teaser Pin
thelastjedi20-Jun-06 4:08
thelastjedi20-Jun-06 4:08 
GeneralRe: c# Brain teaser Pin
izakfick20-Jun-06 4:10
izakfick20-Jun-06 4:10 
AnswerRe: c# Brain teaser Pin
thelastjedi20-Jun-06 4:38
thelastjedi20-Jun-06 4:38 
GeneralRe: c# Brain teaser Pin
izakfick20-Jun-06 4:49
izakfick20-Jun-06 4:49 
GeneralRe: c# Brain teaser Pin
thelastjedi20-Jun-06 5:07
thelastjedi20-Jun-06 5:07 
GeneralRe: c# Brain teaser Pin
izakfick20-Jun-06 5:40
izakfick20-Jun-06 5:40 
AnswerRe: c# Brain teaser Pin
Guffa20-Jun-06 4:09
Guffa20-Jun-06 4:09 
AnswerRe: c# Brain teaser Pin
athulathulsi12-Mar-12 22:06
athulathulsi12-Mar-12 22:06 
class Program
{

static void Main(string[] args)
{
Program pg = new Program();
pg.allTenSum();
Console.ReadLine();
}


public void allTenSum()
{
int check = 0;
string add = "";
int[] a ={ 1, 2, 3, 4, 5, 6, 7, 8, 9 };
List<string> val = new List<string>();
foreach (int abc in a)
{
for (int m = abc; m < 10; m++)
{
if ((m + abc) <= 10)
{
add = Display(abc, m);
foreach (string disp in val)
{
if (disp == add)
check = 1;
}
if (check != 1)
{
if (add != "")
val.Add(add);
}
}
}

}
foreach (string disp in val)
{
Console.WriteLine(disp);
}

}


public string Display(int a, int b)
{
int testTen = 0;
string str = "";
str = str + b + "+" + a;
testTen = testTen + a + b;

while ((testTen + a) < 10)
{
if (str == "")
{
str = str + a;
}
else
{
str = str + "+" + a;
}
testTen = testTen + a;

}
if ((10 - testTen) != 0)
{
int k = 10 - testTen;
str = str + "+" + k;
}
return str;
}

}






Output is :

1+1+1+1+1+1+1+1+1+1
2+1+1+1+1+1+1+1+1
3+1+1+1+1+1+1+1
4+1+1+1+1+1+1
5+1+1+1+1+1
6+1+1+1+1
7+1+1+1
8+1+1
9+1
2+2+2+2+2
3+2+2+2+1
4+2+2+2
5+2+2+1
6+2+2
7+2+1
8+2
3+3+3+1
4+3+3
5+3+2
6+3+1
7+3
4+4+2
5+4+1
6+4
5+5
QuestionList All Web Methods In a WebService!! Pin
Comdesign20-Jun-06 2:27
Comdesign20-Jun-06 2:27 
AnswerRe: List All Web Methods In a WebService!! Pin
Dustin Metzgar22-Jun-06 13:32
Dustin Metzgar22-Jun-06 13:32 
QuestionDisabling keyboard keys Pin
Prashant Gadhave20-Jun-06 2:09
Prashant Gadhave20-Jun-06 2:09 
AnswerRe: Disabling keyboard keys Pin
J4amieC20-Jun-06 2:28
J4amieC20-Jun-06 2:28 
GeneralRe: Disabling keyboard keys Pin
Prashant Gadhave20-Jun-06 2:38
Prashant Gadhave20-Jun-06 2:38 
GeneralRe: Disabling keyboard keys Pin
J4amieC20-Jun-06 2:57
J4amieC20-Jun-06 2:57 
GeneralRe: Disabling keyboard keys Pin
Prashant Gadhave20-Jun-06 18:11
Prashant Gadhave20-Jun-06 18:11 
GeneralRe: Disabling keyboard keys Pin
nueer20-Jun-06 2:55
nueer20-Jun-06 2:55 
GeneralRe: Disabling keyboard keys Pin
thelastjedi20-Jun-06 3:05
thelastjedi20-Jun-06 3:05 
GeneralRe: Disabling keyboard keys Pin
Dan Neely20-Jun-06 3:07
Dan Neely20-Jun-06 3:07 
GeneralRe: Disabling keyboard keys Pin
nueer20-Jun-06 3:27
nueer20-Jun-06 3:27 
GeneralRe: Disabling keyboard keys Pin
Dan Neely20-Jun-06 5:16
Dan Neely20-Jun-06 5:16 
Questionstop pop up Authentication window in asp.net Pin
R_raghu20-Jun-06 2:01
R_raghu20-Jun-06 2:01 
QuestionAnother P/Invoke questions Pin
bluish20-Jun-06 1:54
bluish20-Jun-06 1:54 
QuestionRewrite com interface Pin
pdm12320-Jun-06 1:45
pdm12320-Jun-06 1:45 
QuestionExporting Class Data To XML Pin
Kais4U20-Jun-06 1:24
Kais4U20-Jun-06 1:24 
AnswerRe: Exporting Class Data To XML Pin
Tamimi - Code20-Jun-06 1:50
Tamimi - Code20-Jun-06 1:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.