Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include <ctype.h>
- #include <math.h>
- int funkcija(int *niza, int n) {
- for(int i = 0; i < n; i++) {
- if(niza[i] <= 0) {
- return -1;
- }
- }
- for(int i = 0; i < n; i++) {
- int brojac = 0;
- for(int j = 0; j < n; j++) {
- if(niza[i] == niza[j]) {
- brojac++;
- }
- }
- if(niza[i] != brojac) {
- return 0;
- }
- }
- return 1;
- }
- int main(int argc, char * argv[]) {
- int n;
- scanf("%d", &n);
- int niza[n];
- for(int i = 0; i < n; i++) {
- scanf("%d", &niza[i]);
- }
- int result = funkcija(niza, n);
- printf("%d\n", result);
- }
- /*
- 10
- 2 4 2 4 3 3 3 4 1 4
- **/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement