Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include <math.h>
- int main()
- {
- int wtf, fk, p, resultlen, l1, l2, t, i, j, k, l, m, n, x, y, z, a, b, c, d, count, flag, flag1, len1, len2, flag2;
- char dum, dum2, ch, str[10000], str2[10000], min[10000], max[10000], minreal[10000], result[10000];
- scanf("%d", &t);
- scanf("%c", &dum);
- for (i = 1; i <= t; i++)
- {
- scanf("%s", str);
- scanf("%c", &dum);
- scanf("%s", str2);
- scanf("%c", &dum2);
- len1 = strlen(str);
- len2 = strlen(str2);
- flag2 = 0, wtf = 0;
- if (len1 < len2)
- {
- strcpy(min, str);
- strcpy(max, str2);
- min[len1] = '\0';
- max[len2] = '\0';
- wtf = 2;
- }
- else if (len1 > len2)
- {
- strcpy(min, str2);
- strcpy(max, str);
- min[len2] = '\0';
- max[len1] = '\0';
- wtf = 1;
- }
- else if (len1 == len2)
- {
- z = strcmp(str, str2);
- if (z < 0)
- {
- strcpy(min, str);
- strcpy(max, str2);
- min[len1] = '\0';
- max[len2] = '\0';
- wtf = 2;
- }
- else if (z > 0)
- {
- strcpy(min, str2);
- strcpy(max, str);
- min[len2] = '\0';
- max[len1] = '\0';
- wtf = 1;
- }
- else
- {
- flag2 = 5;
- }
- }
- if (flag2 == 5)
- {
- printf("0\n");
- }
- else
- {
- l1 = strlen(min);
- l2 = strlen(max);
- l = l2 - l1;
- k = 0;
- for (j = 0; j < l; j++, k++)
- {
- minreal[k] = '0';
- }
- p = 0;
- for (k = j; k < l2; k++, p++)
- {
- minreal[k] = min[p];
- }
- minreal[l2] = '\0';
- k = 0;
- p = 0;
- for (j = l2 - 1; j >= 0; j--)
- {
- x = max[j] - 48;
- y = minreal[j] - 48;
- if (k == 1)
- {
- y = y + k;
- }
- if (x < y)
- {
- //y = y + k;
- x = x + 10;
- k = 1;
- }
- else
- {
- k = 0;
- }
- z = x - y;
- result[p] = z + 48;
- p++;
- }
- result[p] = '\0';
- resultlen = strlen(result);
- //printf("%s\n", max);
- //printf("%s\n", minreal);
- //printf("_________________\n");
- fk = 0;
- if (wtf == 2)
- {
- printf("-");
- }
- for (j = resultlen - 1; j >= 0; j--)
- {
- if (result[j] > 48)
- {
- fk = 5;
- }
- if (fk == 5)
- {
- printf("%c", result[j]);
- }
- }
- printf("\n");
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement