473,396 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

C Sharp Combination

Hi everyone

I'm trying to create all possible combinations without repetitions.

I need to create 3 numbers with values from 1-10 with no repetitions.

Ex: 1-2-3
1-3-4
1-2-4
1-3-5
2-3-5
and so on..... I need a loop or something to create all this and fill a 2d array[120,3]
Jul 19 '10 #1

✓ answered by maddyromeo

Expand|Select|Wrap|Line Numbers
  1. using System;
  2. class Program
  3. {   
  4.     static void Main()   
  5.     {
  6.             int[][] data = new int[120][];      
  7.         int index = 0;                
  8.         for ( int a = 1; a <= 8; ++a )      
  9.         {         
  10.             for ( int b = a + 1; b <= 9; ++b )         
  11.             {            
  12.                 for ( int c = b + 1; c <= 10; ++c )             
  13.                 {               
  14.                     data[index++] = new int[] { a, b, c };         
  15.                 }        
  16.             }     
  17.         }     
  18.         for ( int i = 0; i < 120; ++i )      
  19.         {        
  20.             Console.WriteLine("{0:D3} -> {1}-{2}-{3}", i + 1, data[i][0], data[i][1], data[i][2]); 
  21.         }      
  22.         //Console.Read();  
  23.     }
  24. }
i just found this answer from another while googling
this might help......

5 3601
Expand|Select|Wrap|Line Numbers
  1. using System;
  2. class Program
  3. {   
  4.     static void Main()   
  5.     {
  6.             int[][] data = new int[120][];      
  7.         int index = 0;                
  8.         for ( int a = 1; a <= 8; ++a )      
  9.         {         
  10.             for ( int b = a + 1; b <= 9; ++b )         
  11.             {            
  12.                 for ( int c = b + 1; c <= 10; ++c )             
  13.                 {               
  14.                     data[index++] = new int[] { a, b, c };         
  15.                 }        
  16.             }     
  17.         }     
  18.         for ( int i = 0; i < 120; ++i )      
  19.         {        
  20.             Console.WriteLine("{0:D3} -> {1}-{2}-{3}", i + 1, data[i][0], data[i][1], data[i][2]); 
  21.         }      
  22.         //Console.Read();  
  23.     }
  24. }
i just found this answer from another while googling
this might help......
Jul 21 '10 #2
to check the count visit

http://betstarter.com/lottery/3-dig4-digTools.asp
Jul 21 '10 #3
GaryTexmo
1,501 Expert 1GB
Please don't post full solutions. Bytes is about helping people learn, not simply giving them the answer. When you give the solution the person asking the question typically learns nothing.

Try to help them work through the solution first.
Jul 21 '10 #4
yaa GaryTexmo ... i made a mistake, i am not going to repeat it again... thanks for the suggestion...
Jul 22 '10 #5
GaryTexmo
1,501 Expert 1GB
No worries at all, just a heads up for the future :)
Jul 22 '10 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

50
by: Jerry Sievers | last post by:
<venting> Fellow coders; I just get off the phone today with some clueless headhunter and after listing for her (very proudly I might add) my OS and dev tools platforms of choice; ...
0
by: Vi | last post by:
Some of you might be interested in this open source AutoUpdater for ..NET "Sharp AutoUpdater provides an auto-update feature for .NET applications. Using XML configuration files, Sharp...
0
by: application | last post by:
is it possible to create a simple com dll in c-sharp? i need to use a c-sharp com from an asp page( not aspx) and i read in google about regasm and csc and some other strage words but never find a...
1
by: Bo Xu | last post by:
Object of Combination By Bo Xu Introduction A combination of n things, taken s at a time, often referred as an s-combination out of n, is a way to select a subset of size s from a given set of...
2
by: Ben | last post by:
Hi all I am new to C Sharp. Any suggestion for some good C Sharp sites? Thanks for sharing. Ben
4
by: Baskar RajaSekharan | last post by:
Please clarify My doubt.. 1) How to find out whether the component devekopment in Csharp is in Relase Mode or Run Mode? 2) Like Class Id in C++ , what the Unique Id for C-shap Component?
4
by: Hai Nguyen | last post by:
I'm learning C sharp and do not like vb much. I'm creatiing a wepage using panel to test myself. I tried to use these code below, which is written in VB, and to transform them to c sharp but I got...
2
by: HishHish | last post by:
I have a Java code that I want to convert it to C-sharp in order to put it in my ASP.NET web application. I used the JLCA (Java Language Conversion Assistant) for conversion, but it gave me many...
5
by: Alberto | last post by:
What sharp (from c sharp) stand for or where does it comes from? thank you
20
by: windandwaves | last post by:
Hi Folk I am a PHP programmer, but I like to learn c-sharp as it seems to be in hot demand around here. My questions are: - how does c-sharp relate to PHP - do you like c-sharp and its...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.