Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Visual Basic (http://www.programmingforums.org/forum18.html)
-   -   Want Some Nested Loops (http://www.programmingforums.org/showthread.php?t=1037)

kalinga1234 Nov 4th, 2004 10:15 PM

please post some nested loops questions ,becoz i would like to solve it


kalinga B)

kurifu Nov 4th, 2004 10:25 PM

Write a sorting algorithm with convergence of O(n^2) --a bubble sort-- to sort any randomly generated data set of values with a randomly chosen number of element 1 <= n <= 100.

Have fun :P (Actually this is not really complex, lol)

tempest Nov 4th, 2004 11:06 PM

I was going to say bubble sort :( Oh well.

Assuming you know C++:

:

#include <iostream>
#include <conio.h>

bool cArrEq(char first[], char second[]);
void test(char first[], second[]);

void main(int argc, char* argv[]) {
  char tests[3][32] = { "test", "test", "test2"};
  test(tests[0], test[1]);
  test(tests[0], test[2]);
  test(tests[1], test[2]);
  getch();
}

void test(char first[], char second[]) {
  /*
  * This is a runtime function so that
  * the operations in this function dont
  * have to be repeated numerous times in code...
  * -- no need to edit
  */
  printf("%s == %s\t%d\n", first, second, cArrEq(first, second));
}

bool cArrEq(char first[], char second[]) {
  /*
  * This function should return a true/false
  * value pertaining to if first and second
  * are equal to eachother... this should be
  * flexible. char arrays should be able to
  * be of different sizes and still work.
  */
}


Just kidding! I knew this was a VB forum -crawls into fetal position in a corner with an embarassed look-

kalinga1234 Nov 5th, 2004 12:15 AM

hey not fair.. to difficult questions. . post some easy questions ... i am still a beginner to programming you know... Post questions related to visual basic

:P

tempest Nov 5th, 2004 12:26 AM

Alright. Simple challenges... hmmm..

Make code that produces the folling output

1 2 3 4
2 4 6 8
3 6 9 12
4 8 12 16

kalinga1234 Nov 5th, 2004 7:22 AM

too bad I solve the problem.. i need more


:P

kalinga1234 Nov 5th, 2004 7:24 AM

wait i will post the code..


#include<iostream.h>
int main()
{
int row=0,col=0;

for(row=1;row<5;row++)
{
for(col=1;col<5;col++)
{
cout<<row*col;
}
cout<<"\n";
}
return 0;
}

Ooble Nov 5th, 2004 11:45 AM

You said you wanted VB... fine, make an app that asks for a number of lines, and outputs this:

:

1
2 3 4
5 6 7 8 9 10
11 12 13 14 15 16 17 18 19 20
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35


And so on, for the number of lines inputted.

Hint: count the number of numbers in each line.

kurifu Nov 5th, 2004 9:09 PM

Bubble sorts are actually easy stuff, just compare and exchange values... look up how it works on google, since it is a very important algorithm to know anyway ;)

kalinga1234 Nov 6th, 2004 12:20 AM

your question is too difficult ,,I TRIED but cannot do it... wait i'll post the code...
Private Sub Command1_Click()


For x = 1 To 5 Step 1
For y = x To 1 Step -1
Picture1.Print y;
Next y
Picture1.Print
Next x
End Sub


The question you told cannot be done...please post the code... :wacko:


All times are GMT -5. The time now is 8:01 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC