/*
@Author: Mr.Suppakit Thongdee
@Website: www.sourcecode.in.th
*/
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
void Display(char name, int Data[10],int Size){
int i;
printf("%c = [", name);
for(i=0; i<Size; i++){
if(Data[i]>0){
printf("%d ", Data[i]);
}
}
printf("]\n");
}
void main(){
clrscr();
const Size = 10;
int A[Size] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
int B[Size] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int C[Size] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int iRand;
int iValue;
int i, j, k;
int iFound; //0:Not found, 1:Found
//Display A
Display('A', A, Size);
printf("Random time[1-10]:");
scanf("%d",&iRand);
//Random
randomize();
for(i=0; i<iRand; i++){
iValue = random(9)+1;
B[i] = iValue;
}
//Display B
Display('B', B, Size);
//Array C
k = 0;
for(i=0; i<Size; i++){
iFound = 0;
for(j=0; j<iRand; j++){
if(A[i] == B[j]){
iFound = 1;
break;
}
}
//Add data to C
if(iFound ==0){
C[k] = A[i];
k = k+1;
}
}
//Display C
Display('C', C, Size);
getch();
}