Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<string.h>
- #include<stdio.h>
- #include<math.h>
- /*
- //calculating resistance based on first three bands
- int resistance_calc(char a[], char b[], char c[], char d[]){
- int first, second, third, fourth;
- if((strcmp(a, "Brown") || strcmp(a, "BROWN") || strcmp(a, "brown"))==1)
- first = 1;
- if((strcmp(a, "Red") || strcmp(a, "RED") || strcmp(a, "red"))==1)
- first = 2;
- if((strcmp(a, "Orange") || strcmp(a, "ORANGE") || strcmp(a, "orange"))==1)
- first = 3;
- if((strcmp(a, "Yellow") || strcmp(a, "YELLOW") || strcmp(a, "yellow"))==1)
- first = 4;
- if((strcmp(a, "Green") || strcmp(a, "GREEN") || strcmp(a, "green"))==1)
- first = 5;
- if((strcmp(a, "Blue") || strcmp(a, "BLUE") || strcmp(a, "blue"))==1)
- first = 6;
- if((strcmp(a, "Violet") || strcmp(a, "VIOLET") || strcmp(a, "violet"))==1)
- first = 7;
- if((strcmp(a, "Gray") || strcmp(a, "GRAY") || strcmp(a, "gray"))==1)
- first = 8;
- if((strcmp(a, "White") || strcmp(a, "WHITE") || strcmp(a, "white"))==1)
- first = 9;
- else
- printf("Please input a valid first band color (red, orange, yellow, green, violet, gray or white)");
- scanf("%s", a);
- if((strcmp(b, "Black") || strcmp(b, "BLACK") || strcmp(b, "black"))==1)
- second = 0;
- if((strcmp(b, "Brown") || strcmp(b, "BROWN") || strcmp(b, "brown"))==1)
- second = 1;
- if((strcmp(b, "Red") || strcmp(b, "RED") || strcmp(b, "red"))==1)
- second = 2;
- if((strcmp(b, "Orange") || strcmp(b, "ORANGE") || strcmp(b, "orange"))==1)
- second = 3;
- if((strcmp(b, "Yellow") || strcmp(b, "YELLOW") || strcmp(b, "yellow"))==1)
- second = 4;
- if((strcmp(b, "Green") || strcmp(b, "GREEN") || strcmp(b, "green"))==1)
- second = 5;
- if((strcmp(b, "Blue") || strcmp(b, "BLUE") || strcmp(b, "blue"))==1)
- second = 6;
- if((strcmp(b, "Violet") || strcmp(b, "VIOLET") || strcmp(b, "violet"))==1)
- second = 7;
- if((strcmp(b, "Gray") || strcmp(b, "GRAY") || strcmp(b, "gray"))==1)
- second = 8;
- if((strcmp(b, "White") || strcmp(b, "WHITE") || strcmp(b, "white"))==1)
- second = 9;
- else
- printf("Please input a valid second band color (black, red, orange, yellow, green, violet, gray or white)");
- scanf("%s", b);
- if((strcmp(c, "Black") || strcmp(c, "BLACK") || strcmp(c, "black"))==1)
- third = 0;
- if((strcmp(c, "Brown") || strcmp(c, "BROWN") || strcmp(c, "brown"))==1)
- third = 1;
- if((strcmp(c, "Red") || strcmp(c, "RED") || strcmp(c, "red"))==1)
- third = 2;
- if((strcmp(c, "Orange") || strcmp(c, "ORANGE") || strcmp(c, "orange"))==1)
- third = 3;
- if((strcmp(c, "Yellow") || strcmp(c, "YELLOW") || strcmp(c, "yellow"))==1)
- third = 4;
- if((strcmp(c, "Green") || strcmp(c, "GREEN") || strcmp(c, "green"))==1)
- third = 5;
- if((strcmp(c, "Blue") || strcmp(c, "BLUE") || strcmp(c, "blue"))==1)
- third = 6;
- if((strcmp(c, "Violet") || strcmp(c, "VIOLET") || strcmp(c, "violet"))==1)
- third = 7;
- if((strcmp(c, "Gray") || strcmp(c, "GRAY") || strcmp(c, "gray"))==1)
- third = 8;
- if((strcmp(c, "White") || strcmp(c, "WHITE") || strcmp(c, "white"))==1)
- third = 9;
- else
- printf("Please input a valid third band color (black, red, orange, yellow, green, violet, gray or white)");
- scanf("%s", c);
- if((strcmp(d, "Silver") || strcmp(d, "SILVER") || strcmp(d, "silver"))==1)
- fourth = pow(10,-2);
- if((strcmp(d, "Gold") || strcmp(d, "GOLD") || strcmp(d, "gold"))==1)
- fourth = pow(10, -1);
- if((strcmp(d, "Black") || strcmp(d, "BLACK") || strcmp(d, "black"))==1)
- fourth = pow(10, 0);
- if((strcmp(d, "Brown") || strcmp(d, "BROWN") || strcmp(d, "brown"))==1)
- fourth = pow(10, 1);
- if((strcmp(d, "Red") || strcmp(d, "RED") || strcmp(d, "red"))==1)
- fourth = pow(10, 2);
- if((strcmp(d, "Orange") || strcmp(d, "ORANGE") || strcmp(d, "orange"))==1)
- fourth = pow(10, 3);
- if((strcmp(d, "Yellow") || strcmp(d, "YELLOW") || strcmp(d, "yellow"))==1)
- fourth = pow(10, 4);
- if((strcmp(d, "Green") || strcmp(d, "GREEN") || strcmp(d, "green"))==1)
- fourth = pow(10, 5);
- if((strcmp(d, "Blue") || strcmp(d, "BLUE") || strcmp(d, "blue"))==1)
- fourth = pow(10, 6);
- if((strcmp(d, "Violet") || strcmp(d, "VIOLET") || strcmp(d, "violet"))==1)
- fourth = pow(10, 7);
- if((strcmp(d, "Gray") || strcmp(d, "GRAY") || strcmp(d, "gray"))==1)
- fourth = pow(10, 8);
- if((strcmp(d, "White") || strcmp(d, "WHITE") || strcmp(d, "white"))==1)
- fourth = pow(10, 9);
- else
- printf("Please input a valid fourth band color (silver, gold, black, red, orange, yellow, green, violet, gray or white)");
- scanf("%s", d);
- return (((first*100)+(second*10)+(third))*fourth);
- }
- */
- int main(void)
- {
- char *bands[6][10];
- //int i;
- //float resistance;
- scanf("%s %s %s %s %s %s", bands[0][0], bands[1][0], bands[2][0], bands[0][3], bands[4][0], bands[5][0]);
- printf("%s",bands[0][0]);
- printf("%s",bands[1][0]);
- printf("%s",bands[2][0]);
- printf("%s",bands[3][0]);
- printf("%s",bands[4][0]);
- printf("%s",bands[5][0]);
- //resistance = resistance_calc(bands[0], bands[1], bands[2], bands[3]);
- //printf("%10.4f Ohms\n", resistance);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement