answersLogoWhite

0

#include<iostream>

#include<iomanip>

#include<time.h>

template<typename T>

size_t find(T& data, T a[], size_t size)

{

size_t index=0;

do {

if(a[index]==data)

break;

} while(++index<size);

return(index);

}

template<typename T>

void print(T a[], size_t size)

{

using std::cout;

using std::endl;

using std::setw;

size_t index=0;

do{

if(index&&index%20==0)

cout<<endl;

cout<<setw(3)<<a[index];

}while(++index<size);

cout<<endl;

}

int main()

{

srand((unsigned)time(NULL));

const size_t size=100;

unsigned int a[size];

size_t index=0;

do{

unsigned int data=rand()%100;

do{

data=rand()%100;

} while(find(data,a,index)<index);

a[index]=data;

} while(++index<size);

print(a,size);

}

User Avatar

Wiki User

11y ago

What else can I help you with?

Related Questions

Write a JSP program which displays webpage containing arrival of new items within a particular month in the different branches of a retail company?

vbcvbvbvcbc vbcvbvbvcbc


Write a c program on reverse the diagonal element of matrix?

mano ni anda yarrr


What is the functional of a bus?

The bits of address bus inform the memory(Ram) which particular element is to be read or write in memory.


Write c program to find median?

If you are using an array : sort using qsort() then take middle element.


Write a problom that can be solved by making a table and using a pattern Then solve the problem?

You can draw a flowchart of solving a particular problem and then write a program to solve that problem.


How can I write a program to display prime numbers from 1 to 100?

Write a function that implements an algorithm that checks to see if a particular integer is prime (returning a boolean). Write a program that uses that function on each number from 1 to 100, and if true, displays that number.


Is it more efficient to store the data in a matrix then write it to the file at the end of the program or to write each element to the file as the program runs?

It shouldn't make significant difference, only if the matrix is huge -- in that case you shouldn't store it in memory.


A program written in a high-level programming language is called?

the program written in high level language is called "source program"


Write to him.He will answer you?

Write to whom in particular?


Write a program to find out the address of an element in an array?

== Java does not allow reference to memory locations. == In C: for (i=0; i&lt;n; ++i) printf ("a[%d] is at %p\n", i, &amp;a[i]);


How do you write a java program to find the transpose of the matrix for the given elements?

You basically write a nested for loop (one for within another one), to copy the elements of the matrix to a new matrix.


How to write program for secant method in mathematica?

How to write a program for secant method by mathematica