Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #define MAXBRAND 31
- #define MAXMODEL 40
- #define MAXAUTO 500
- struct techInfo {
- int cv,cili,val;
- };
- typedef struct car {
- char brand[MAXBRAND],model[MAXMODEL];
- int fabYear;
- struct techInfo techData;
- }car;
- void inputCars(car autos[]);
- float performCheck(car autos);
- void showAll(car autos[]);
- int shitCarsCounter(car autos[]);
- int main() {
- struct car autos[MAXAUTO];
- inputCars(autos);
- printf("LISTAGEM DE VEICULOS:\n");
- showAll(autos);
- printf("Quantidade de carros com performance abaixo de 150 : %d\n",shitCarsCounter(autos));
- return 0;
- }
- void inputCars(car autos[]) {
- int i;
- for (i = 0; i < MAXAUTO; i++) {
- printf("Entre com a marca do carro :\n");
- gets(autos[i].brand);
- printf("Entre com o modelo do carro :\n");
- gets(autos[i].model);
- printf("Entre com o ano de fabricacao :\n");
- scanf("%d",&autos[i].fabYear);
- printf("Entre com os CV :\n");
- scanf("%d",&autos[i].techData.cv);
- printf("Entre com as cilindradas :\n");
- scanf("%d",&autos[i].techData.cili);
- printf("Entre com a quantidade de valvulas :\n");
- scanf("%d",&autos[i].techData.val);
- fflush(stdin);
- }
- }
- float performCheck(car autos) {
- if (autos.techData.val >= 16)
- return (3*autos.techData.cv + autos.techData.cili)/(float)autos.techData.val;
- else
- return (2*autos.techData.cv + autos.techData.cili)/(float)autos.techData.val;
- }
- void showAll(car autos[]) {
- int i;
- for (i = 0; i < MAXAUTO; i++) {
- printf("Marca : %s\nModelo : %s\nAno de fabricacao : %d",autos[i].brand,autos[i].model,autos[i].fabYear);
- printf("\nCV : %d\nCilindradas : %d\nValvulas : %d\n",autos[i].techData.cv,autos[i].techData.cili,autos[i].techData.val);
- printf("Performance estrutural : %f\n\n\n",performCheck(autos[i]));
- }
- }
- int shitCarsCounter(car autos[]) {
- int i,counter = 0;
- for (i = 0; i < MAXAUTO; i++)
- if (performCheck(autos[i]) < 150)
- counter++;
- return counter;
- }
Advertisement
Add Comment
Please, Sign In to add comment