Asp.net calculates the combination of three digits

Source: Internet
Author: User

Simple: CopyCode The Code is as follows: public partial class _ default: system. Web. UI. Page
{
String M1 = "";
Protected void page_load (Object sender, eventargs E)
{
String n = "123 ";
String M = "";
Zuhe (N );
For (Int J = 2; j>-1; j --)
{
M = m + n [J];
}
Zuhe (m );
}
Private void zuhe (string SSEL)
{
For (INT I = 0; I <SSEL. length; I ++)
{
M1 = SSEL + SSEL. substring (I, 1 );
Response. Write (m1.remove (I, 1) + "<br> ");
}
}
}

Csdn (xiaoshen1127): winformCopy codeThe Code is as follows: using system;
Using system. Collections. Generic;

Namespace zuheshu
{
Class Program
{

Static void main (string [] ARGs)
{

program P = new program ();
console. writeline ("******************************* number of combinations ***** ******************************");
console. writeline ("enter any integer:");
string num = console. readline ();
try {
long. parse (Num);
List als = new list ();
als = P. getdata (string. empty, num. trim (), als);
P. display (ALS);
console. writeline ("\ NY-Enter: continue");
If (Console. readline (). trim (). tolower () = "Y")
{< br> console. clear ();
main (ARGs);
}< BR >}< br> catch {
console. clear ();
console. writeline ("enter a number! ");
main (ARGs);
}< BR >}

Private list <string> getdata (string strbase, string strsel, list <string> alret)
{
If (strsel. Length = 1)
{
String temp = strbase + strsel;
If (! Alret. Contains (temp )&&! Temp. startswith ("0 "))
{
Alret. Add (temp );
}
}
Else
{
For (INT I = 0; I <strsel. length; I ++)
{
Getdata (strbase + strsel. substring (I, 1), strsel. Remove (I, 1), alret );
}
}
Return alret;
}

Public void display (list <string> Dals)
{
Int I = 1;
Int A = Dals. count;
If (A = 0)
{
Console. writeline ("this number has no other combinations ");
}
Else
{
Console. writeline ("Total number of different combinations" + A + ", as shown below ");
Foreach (string number in Dals)
{
Console. Write (number + "\ t ");
If (I ++ % 5 = 0)
{
Console. writeline ();
}
}
}
}
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.