Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int make_it_three(char c1, char c2, char c3)
- {
- int d1, d2, d3, result = 0;
- if((c1 >= 48 && c1 <= 57) && (c2 >= 48 && c2 <= 57) && (c3 >= 48 && c3 <= 57))
- {
- for(int i = 48; i <= 57; i++)
- {
- if (c1 == i)
- {
- d1 = i - 48;
- break;
- }
- }
- for(int j = 48; j <= 57; j++)
- {
- if (c2 == j)
- {
- d2 = j - 48;
- break;
- }
- }
- for(int k = 48; k <= 57; k++)
- {
- if (c3 == k)
- {
- d3 = k - 48;
- break;
- }
- }
- result += d1;
- result = (result * 10) + d2;
- result = (result * 10) + d3;
- return result;
- }
- return 0; // If all three chars are not digits.
- }
- void main()
- {
- char c1 = '1', c2 = '9', c3 = '3';
- int result = make_it_three(c1, c2, c3);
- printf("%d\n", result);
- }
Add Comment
Please, Sign In to add comment