Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #define N 12
- #define TOMB_INICIALIZALAS
- int main(void){
- int i;
- int db=0;
- #ifdef TOMB_INICIALIZALAS
- double tomb[]={289.5, 292.6, 290.2, 285.5, 300.4, 300.3, 302.5, 308.3, 303.5, 299.9, 302.3, 305.1};
- #else
- double tomb[N];
- char karakter;
- int jo;
- int beolvasott_adatok_szama;
- #endif
- double limit=300.0;
- int monoton;
- int min_index=0;
- int max_index=0;
- monoton=1;
- printf("HUF/EUR folyamok:\n");
- for (i=0; i<N; i++){
- #ifndef TOMB_INICIALIZALAS
- jo=0;
- do{
- printf("%d. ertek: ", i+1);
- beolvasott_adatok_szama=scanf("%lf", &tomb[i]);
- if (beolvasott_adatok_szama==1)
- jo=1;
- else{
- if (beolvasott_adatok_szama==-1)
- printf("\n");
- printf("Hibas adat. Kerem adja meg ujra!\n");
- if (beolvasott_adatok_szama==0)
- while ((karakter=getchar())!='\n');
- }
- } while (!jo);
- #else
- printf("%d. ertek: %.1lf\n", i+1, tomb[i]);
- #endif
- if (tomb[i]<limit)
- db++;
- if (i!=0 && tomb[i]<tomb[i-1])
- monoton=0;
- }
- for(i=1; i<N; i++){
- if(tomb[i]<tomb[min_index]){
- min_index=i;
- }
- if(tomb[i]>tomb[max_index]){
- max_index=i;
- }
- }
- printf("\nAz arfolyam erteke %.1lf Ft alatt volt %d esetben.\n", limit, db);
- printf("\nA sorozat monoton nott? %s", monoton ? "Igaz\n" : "Hamis\n");
- printf("\nA sorozat legkisebb eleme: %.1lf, sorszama: %d\n", tomb[min_index], min_index+1);
- printf("\nA sorozat legnagyobb eleme: %.1lf, sorszama: %d\n\n", tomb[max_index], max_index+1);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment