Created
May 11, 2011 13:36
-
-
Save heartnet/966455 to your computer and use it in GitHub Desktop.
sample1.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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