Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- /* run this program using the console pauser or add your own getch, system("pause") or input loop */
- int main(int argc, char *argv[])
- {
- char nazwy[50][20];
- float ceny[50];
- int j=0;
- int k=0;
- int i=0;
- int n=0;
- int m=0;
- do
- {
- fflush(stdin);
- printf("Podaj towar nr %d\n", i+1);
- scanf("%s", &nazwy[i]);
- printf("A teraz jego cene\n");
- scanf("%f", &ceny[i]);
- // printf("%s",nazwy[i]);
- i++;
- }while(strcmp("stop",nazwy[i-1]));
- float maxcena;
- maxcena=0;
- char nazwynowe[i][20];
- for(j;j<i;j++)
- {
- if(maxcena<ceny[j])maxcena=ceny[j];
- }
- j=0;
- for(j;j<i-1;j++)
- {
- if(ceny[j]>maxcena/2)
- {
- strcpy(nazwynowe[k],nazwy[j]);
- n++;
- k++;
- }
- }
- printf("Towary z cena wieksza od max/2: \n");
- for(m;m<n;m++)
- {
- printf("%s\n",nazwynowe[m]);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement