Judge Info
- Memory Limit: 32768KB
- Case Time Limit: 10000MS
- Time Limit: 10000MS
- Judger: Normal
Description
Please calculate the answer of A*B, both A and B are integer.
Input
The first line of input contains , the number of test cases. There is only line for each test case. It contains two integers .
Output
For each test case, output A*B in one line.
Sample Input
3 1 2 1 1 -1 -1
Sample Output
2 1 1
Ps : 算法课的小练习,通过字符串处理。注意0就OK了。
1 #include <stdio.h> 2 #include <string.h> 3 4 char A[200]; 5 char B[200]; 6 int C[200+200+1]; 7 8 char *revstr(char *str, int len){ 9 char *start = str; 10 char *end = str + len - 1; 11 char ch; 12 if(str != 0){ 13 while(start < end){ 14 ch = *start; 15 *start ++ = *end; 16 *end-- = ch; 17 } 18 } 19 return str; 20 } 21 22 int main(int argc, char const *argv[]) 23 { 24 int t, i, j, lenA, lenB, len, Amark, Bmark, mark; 25 scanf("%d", &t); 26 while(t--){ 27 28 mark=0; 29 Amark = 0; 30 Bmark = 0; 31 32 memset(A, '0', sizeof(A)); 33 memset(B, '0', sizeof(B)); 34 memset(C, 0, sizeof(C)); 35 scanf("%s", A); 36 scanf("%s", B); 37 lenA = strlen(A); 38 lenB = strlen(B); 39 40 if(A[0] == '-'){ 41 for(i=1;i<lenA;++i) 42 A[i-1] = A[i]; 43 A[i-1]= '