Skip to content

Instantly share code, notes, and snippets.

@heartnet
Created May 11, 2011 13:36
Show Gist options
  • Save heartnet/966455 to your computer and use it in GitHub Desktop.
Save heartnet/966455 to your computer and use it in GitHub Desktop.
sample1.c
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define SIZE 100
int* cmpl(int *Set);
int main(int argc, char *argv[]) {
int i;
int Array[SIZE];
int *addr;
srand((unsigned)time(NULL));
for (i = 0; i < SIZE; i++) {
Array[i] =rand() % 2;
} // for
addr =cmpl(Array);
for (i = 0; i < SIZE; i++) {
printf("%d ", addr[i]);
} // for
return 0;
} // function
int* cmpl(int *Set) {
int i;
int Complement[SIZE];
for (i = 0; i < SIZE; i++) {
if (Set[i] == 1) {
Complement[i] =0;
} else {
Complement[i] =1;
} // if
} // for
return Complement;
} // function
/* [EOF] */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment