|
Sounds like homework. In order to get help with homework you need to show willing to have a try yourself and ask questions when you get stuck. Nobody is going to write the code for you.
I can give you some tips to get started.
1) Fill a list with the 9 possible values
2) Get a random number between 0-8
3) Get this item out of the list (remember to remove it) and add it to position 0 in the Array
4) Get a random number between 0-7
5) Get this item out of the list (remember to remove it) and add it to position 1 in the Array
6) Rinse/repeat until the array is full.
|
|
|
|
|
Random rnd = new Random();
int[] sayilar = new int[9];
for (int i = 0; i < 9; i++)
{
int rastgele = rnd.Next(1, 9);
sayilar[i] = rastgele;
}
Above, I can construct the array members randomly but, my problem is that,
For example, I gave 7 to sayilar[1], after that I can't remove 7 from number list. Because the sayilar[2] can't be 7 but the others members of array can be 7.
My condition is not that all members have different values , I want only sayilar[1] is different from sayilar[2] and sayilar[4] is different from sayilar[5].
sayilar[7],sayilar[8],sayilar[6],sayilar[3] can have the same value. I give numbers to members as randomly.
|
|
|
|
|
Go back and read my tips. You need an Array and a List.
The list contains the available numbers, once a number is used it is removed from the list.
This is a very easy problem and just needs some thought on how to not duplicate the numbers into the destination array.
|
|
|
|
|
I can't explain my question. Removing is not right way for me because the number ,used for sayilar[1], can be used other members of array only can't be used forsayilar[2].
|
|
|
|
|
Isn't there any response?
|
|
|
|
|
foreach number required {
forever {
generate a random number;
if you like it {
store it;
break;
}
}
}
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use PRE tags to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Sorry, I didn't understand your response.
|
|
|
|
|
it basically says "if you don't like a random number, roll the dices again".
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use PRE tags to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Hello!
I found on a website that i need the MySQL OleDB Provider to connect to a MySQL database from C#. I installed the provider but i don't know how to use it. Do i have to use OleDbConnection or OdbcConnection? Or is there an easier way?
Thank you
|
|
|
|
|
ConnectionStrings.com[^] has all the information you need.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
hi
Is their any one who know about sharp map mathods.I want to draw or render line between two point(long,lati) dynamiticaly,but I don't know how to do it.
Please help me with example and help.
nemo
|
|
|
|
|
Hi,
You can use the Graphics.Transform property of your graphics object to set a Matrix that takes care of the rotation (use the Matrix.Rotate method) of your text in case your two points are at different lattitudes. After that, just use Graphics.DrawString to render your text, be sure to take into account that the matrix transformation influences your grid positions too.
Standards are great! Everybody should have one!
|
|
|
|
|
Hi, Can AnyOne give Me A Good ref of an TCO/IP article
i did not found any Beginners article Here
THANKS
Have Fun
Never forget it
|
|
|
|
|
Hi Dear,
Go this Goddysss
http://www.w3schools.com/tcpip/default.asp
You will find somthing to learn.
Thanks
"Good Thing Goes With Good People..."
|
|
|
|
|
THANKS
i Already Been there
i was looking for something in C#
Have Fun
Never forget it
|
|
|
|
|
Hi All :
I have create a program in C# but I want when I click on a Search device button it begin to search devices in bluetooth ,the discoverd devices I want to but them in a list box ..... please any one can help..........
Thanks
|
|
|
|
|
Hi. I have a question regarding the auto-generated InitializeComponent() code when using visual studio. For example, if I have a form and a user control. Now, when I drag the user-control onto the form VS automatically instanciates the user-control inside the InitializeComponent() method. But say I have a property in the user-control I want to set through it's constructor, ie. passing some parameter when istansiating the user-control. How can I do this without editing the InitializeComponent() in the code-editor?
|
|
|
|
|
To use your UserControl within the VS Designer it has to have a default constructor.
I see two solutions to your problem:
1) let everything the way it is now and add a property set what you have to set.
2) Add your UserControl dynamically (with the constructor with your parameters) in the Load event of your Form.
If you want designer support then I'd suggest you use solution 1. The property value can be set either in the designer (if it is a constant value) or somewhere in the code.
Happy coding
-^-^-^-^-^-^-^-^-^-^-^-
no code is free of bugs
|
|
|
|
|
hi,
after fetching the data into the datagridview, how to display the value of a particular field of a selected row, in a textbox.
Nitin Raj Bidkikar
|
|
|
|
|
Hi,
for that you have to start with evetn of SelectedIndex Changing of gridview.
in that u will get selectedindex using e.RowIndex..
Now u can get any cell's value from that.
Thanks,
Sun Rays
To get something you must have to try once.
My Articles
|
|
|
|
|
Iam using datagridview and not gridview, its a windows application, not an asp. there is no selected index available .please help
Nitin Raj Bidkikar
|
|
|
|
|
Hi,
check this.. it will help you.
Thanks,
Sun Rays
To get something you must have to try once.
My Articles
|
|
|
|
|
Hi Dear.
TextBox1.Text = GridView1.Rows[GridView1.SelectedIndex].Cells[1].Text;
Write this in your GridViewChanging or Some Button Click event will help you....sure...
Thanks
"Good Thing Goes With Good People..."
|
|
|
|
|
your solution doesnt word, as Iam using datagridview and not gridview, its a windows application, not an asp.
the selectedindex is not provided in datagridview
please help
Nitin Raj Bidkikar
|
|
|
|
|
Hello everybody!!!!
I am Pradhuman.
I have to apply the progressbar along with status of the task to show in C#, for windows appliction.
for example : suppose in a file i have 100 records. while progressing the progressbar it has to show out of 100 record how many has been mapped like this.
can anybody send me the code for the above senario help me out.
regards,
pradhuman
thanx sun rays
here with i tried the follwoing code, but its not working as i want. Only progressbar is showing not the activity ststus....
private void button1_Click(object sender, System.EventArgs e)
{
for(int i=progressBar1.Minimum; i<=progressBar1.Maximum; i++)
{
progressBar1.PerformStep();
}
float fpercent = 0;
int counter = 0;
int file = 120;
do
{
fpercent = (float)counter / (float)file * 100;
updateprogress((int)fpercent);
counter++;
}while (fpercent < 100);
// if (progressBar1.Value == progressBar1.Maximum)
// {
// progressBar1.Value = progressBar1.Minimum;
// }
// progressBar1.PerformStep();
//label1.Text=progressBar1.Value.ToString() ;
}
public void updateprogress(int npercent)
{
progressBar1.Value = npercent;
}
plz help me out
-- modified at 3:38 Tuesday 27th November, 2007
|
|
|
|