Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <stdio.h>
- typedef struct{
- int gramas;
- float bits;
- float price;
- }Mercado;
- main()
- {
- int sup, c, index;
- printf("Digite o numero de supermercados proximos a Maria\n");
- scanf("%i", &sup);
- fflush(stdin);
- Mercado mercados[sup];
- for(c = 0; c < sup; c++){
- scanf("%f %i", &mercados[c].bits, &mercados[c].gramas);
- fflush(stdin);
- mercados[c].price = 1000 * mercados[c].bits / mercados[c].gramas;
- };
- for(c = 0; c < sup; c++){
- if(c == 0){
- index = c;
- }else{
- if(mercados[c].price < mercados[index].price){
- index = c;
- };
- };
- };
- printf("%.2f", mercados[index].price);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement