wow, um... I think this is supposed to let the user enter 8 ints, find the min and max, and print them out sorted. Which is what it does. Hard to say though since I don't speak the language. (is that Russian?)
If that's what you were trying to do, you succeeded. What is your question?
also suc+=pole[i] made me giggle. I'm such a child. :)
you could find the min and max in one pass through the array:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
int max=pole[0];
int min=pole[0];
int suc=0;
for( i=0; i<N; i++ ) {
if( pole[i]>max ) {
max=pole[i];
}
if( pole[i]<min ) {
min=pole[i];
}
suc+=pole[i]; // obligatory juvenile sniggering
}
printf( "\nMaximum v poli je %d\n", max );
printf( "\nMinimum v poli je %d\n", min );
#include <stdio.h>
#include <stdlib.h>
#define N 8
int main()
{
int pole[N];
int q,i;
do {
printf("Zadajte max %d prvkov pola\n", N);
for (i=0; i<N; i++) {
scanf("%d", &pole[i]);
}
printf("Zadane prvky pola: \n");
for (i=0; i<N; i++) {
printf("%d\n", pole[i]);
}
printf("Zadane prvky opacne:\n");
for (i=N-1; i>=0; i--) {
printf("%d\n", pole[i]);
}
int max=pole[0];
for (i=0; i<N; i++) {
if (pole[i]>max) {
max=pole[i];
}
}
printf("\nMaximum v poli je %d\n", max);
int min=pole[0];
for (i=0; i<N; i++) {
if (pole[i]<min) {
min=pole[i];
}
}
printf("\nMinimum v poli je %d\n", min);
float priem;
int suc=0;
for (i=0; i<N; i++) {
suc+=pole[i];
}
priem=(float)suc/N;
printf("Priemer prvkov pola je %f\n", priem);
printf("Zotriedene pole:\n");
int pom,j;
for (j=0; j<N; j++) {
for (i=0; i<N-1; i++) {
if (pole[i]>pole[i+1]) {
pom=pole[i];
pole[i]=pole[i+1];
pole[i+1]=pom;
}
}
}
for (j=0; j<N; j++) {
printf("%d\n", pole[j]);
}
printf("POKRACOVAT? \n 1=ANO \n 0=NIE \n");
scanf("%d", &q);
} while (q);
return 0;
}