Advertisement
domdealm

Questão dos Resistores - PréProva2

Jan 26th, 2017
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.13 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #define mf i=0;i<5;i++
  4.  
  5.  
  6. typedef struct cores{
  7.     int a;
  8.     int b;
  9.     int c;
  10.     int d;
  11. }cor;
  12.  
  13. int main(){
  14.     float tol[12] = {0,1,2,0,0,0.5,0.25,0.1,0.05,0,5,10};
  15.     char zer[][30] = {"0","00","x10³","x10⁴","x10⁵",
  16.                       "x10⁶","x10⁷","x10⁸","x10⁹"};
  17.     cor c[5];
  18.     int i=0,k=1;
  19.     for(mf){
  20.         printf("Menu de cores:\n 0 - Preto\n 1 - Marrom\n 2 - Vermelho\n 3 - Laranja\n 4 - Amarelo\n 5 - Verde\n 6 - Azul\n 7 - Violeta\n 8 - Cinza\n 9 - Branco\n TOLERANCIA:\n 10 - Dourado\n 11 - Prata\n\n ");
  21.         printf("Resistor %d: \n",i+1);
  22.         printf("cor1: ");
  23.         scanf("%d",&c[i].a);
  24.         printf("cor2: ");
  25.         scanf("%d",&c[i].b);
  26.         printf("cor3: ");
  27.         scanf("%d",&c[i].c);
  28.         printf("cor4: ");
  29.         scanf("%d",&c[i].d);
  30.         printf("\n-----------------------\n");
  31.     }
  32.     system("clear");
  33.     printf("Valores:\n");
  34.  
  35.     for(mf){
  36.         printf("\nResistor %d: %d%d%s",i+1,c[i].a,c[i].b,zer[(c[i].c)-1]);
  37.         printf("ohms com %g de tolerancia. \n",tol[c[i].d]);
  38.         printf("\n------------------------\n");
  39.     }
  40.     //system("PAUSE"); //para funcionar no windows só apagar o getchar e descomentar essa linha
  41.     getchar();
  42.     return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement