The first algorithm has a big problem. Not found
Copy codeThe Code is as follows: static void Main (string [] args)
{
//
// TODO: Add code here to start the application
Int singletitlemeasure = 5;
Int n = 1; // declare an int variable that represents the test Type
Random ran = new Random (unchecked (int) DateTime. Now. Ticks ));
Int Int1Random;
Switch (n)
{
Case 1: // indicates a single answer
{
Int I = 1, k = 1;
Int [] ** I = new int [singletitlemeasure + 1]; // declare an array used to save question numbers
Int temp; // declare an array that temporarily saves random values
Int1Random = ran. Next (1, singletitlemeasure );
** I = Int1Random;
Console. WriteLine ("** I [" + I + "] =" + ** I );
Do
{K = 1; Int1Random = ran. Next (1, singletitlemeasure); temp = Int1Random; Console. WriteLine ("temp:" + temp); do {if (temp! = ** I [k]) {
Console. WriteLine ("** I [" + k + "] =" + ** I [k]);
K ++;
Console. WriteLine ("looping" + (k-1) + "times ");
}
Else
{
I --;
Console. writeLine ("I =" + I) ;}} while (k <I); I ++; ** I = temp; Console. writeLine ("** I [" + I + "] =" + ** I);} while (I <= singletitlemeasure-1); for (I = 1; I <= 5; I ++)
{Console. Write ("Int1Random ="); Console. WriteLine (** I );
} Break;
}
Case 2: // indicates multiple choice questions {Console. WriteLine ("Int2Random ="); break;
}
Case 3: // indicates a question.
{
Console. WriteLine ("Int3Random = ");
Break;
}
Default:
{Console. WriteLine ("Invalid selection. Please select 1, 2, or 3 .");
}
Break;
}
Console. Read ();
}
Copy codeThe Code is as follows: using System;
Namespace Temp
{
/// <Summary>
/// Summary of Class1.
/// </Summary>
Class Class1
{
/// <Summary>
/// Main entry point of the application.
/// </Summary>
[STAThread]
Static void Main (string [] args)
{
//
// TODO: Add code here to start the application
Int singletitlemeasure = 20; // number in the question bank
Int Int1Random; // random number generated temporarily
Int [] ** I = new int [singletitlemeasure + 1]; // declare an array used to save question numbers
Bool bflag = true;
Bool bFlag = true;
Int n = 1; // declare an int variable that represents the test Type
Int I = 1; // number of declared Outer Loops
Switch (n)
{
Case 1: // indicates a single answer
{
Do
{
// Random ran = new Random (unchecked (int) DateTime. Now. Ticks); // this Random number is somewhat regular.
Random ran = new Random (unchecked (int) DateTime. now. millisecond); // this random number is more random than some Int1Random = ran. next (1, singletitlemeasure + 1 );
// ** I = Int1Random;
// Console. WriteLine ("** I [" + I + "] =" + ** I );
Console. WriteLine ("Int1Random =" + Int1Random );
Int temp = Int1Random;
If (bFlag = true)
{
** I = Int1Random;
Console. WriteLine ("** I [" + I + "] =" + ** I );
BFlag = false;
I ++;
}
Else
{
Bflag = true;
Int k = 1; // number of declared inner Loops
Do
{
If (temp = ** I [k])
{
// Console. WriteLine ("** I [" + k + "] =" + ** I [k]);
Bflag = false;
Break;
}
K ++;
} While (k <I );
If (bflag = true)
{
** I [k] = temp;
Console. WriteLine ("** I [" + I + "] =" + ** I );
I ++;
}
}
} While (I <= 5 );
For (I = 1; I <= 5; I ++)
{
Console. WriteLine ("** I [" + I + "] =" + ** I );
}
Break;
}
Case 2: // multiple answer questions
{
Console. WriteLine ("Int2Random = ");
Break;
}
Case 3: // indicates a question.
{
Console. WriteLine ("Int3Random = ");
Break;
}
Default:
{
Console. WriteLine ("Invalid selection. Please select 1, 2, or 3 .");
}
Break;
}
Console. Read ();
//
}
}
}