Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- #define MAXLENGTH 25
- int main(){
- int a=10, b=99, i, j, k, z=0;
- int pom, max;
- int polje[MAXLENGTH]={0}, novo[MAXLENGTH]={0};
- srand((unsigned)time(0));
- for (i=0; i<MAXLENGTH; i++){
- polje[i] = a + rand() % (b - a + 1);
- }
- printf("Prvo polje:\n");
- for (i=0; i<MAXLENGTH; i++){
- printf("%d ", polje[i]);
- }
- printf("\n\n");
- for(i=0; i<MAXLENGTH-1; i++){
- max = i;
- for (j=i+1; j<MAXLENGTH; j++)
- if (polje[j] > polje[max])
- max = j;
- pom = polje[i];
- polje[i]=polje[max];
- polje[max]=pom;
- }
- printf("Silazno sortirano polje je:\n");
- for(i=0; i<MAXLENGTH; i++){
- printf("%d ", polje[i]);
- }
- printf("\n\n");
- for(i=0; i<MAXLENGTH; i++){
- if (polje[i] %2 != 0){
- novo[z]=polje[i];
- z++;
- }
- }
- printf("Ima %d neparnih clanova polja a to su:\n", z);
- for(i=0; i<z; i++){
- printf("%d ", novo[i]);
- }
- printf("\n\n");
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement