记录详情

Compile Error

/in/foo.c: In function 'main':
/in/foo.c:10:2: warning: implicit declaration of function 'scan' [-Wimplicit-function-declaration]
  scan("%d", &T); 
  ^~~~
/tmp/ccrpGBKw.o: In function `main':
foo.c:(.text.startup+0x1e): undefined reference to `scan'
foo.c:(.text.startup+0x5b): undefined reference to `scan'
foo.c:(.text.startup+0x81): undefined reference to `scan'
foo.c:(.text.startup+0xbc): undefined reference to `scan'
collect2: error: ld returned 1 exit status

代码

#include<stdio.h>

int gcd(int m, int n) {
	if (n == 0) return m;
	return gcd(n, m % n);
}

int main() {
	int T,n,num1[9999],num2[9999],i,temp;
	scan("%d", &T); 
	while (T > 0) { //节约出了一个变量i
		//数据的输入,其实每次只需要看最后一个数据就行
		scan("%d", &n);
		n++;
		for (i = 0; i < n; i++) { scan("%d", &num1[i]); }
		for (i = 0; i < n; i++) { scan("%d", &num2[i]); }
		//for (i = 0; i < n; i++) { printf("%d", num1[i]); }
		//for (i = 0; i < n; i++) { printf("%d", num2[i]); }
		//下面开始各种情况的列举
		i--;
		if (num1[i] != 0 && num2[i] != 0) { //上下的次数相同,即有答案,则主要目标是考虑约分的问题
			if (num1[i] % num2[i] == 0 || num2[i] % num1[i] == 0) {
				if (num1[i] > num2[i]) {
					temp = gcd(num1[i], num2[i]);
				}
				else {
					temp = gcd(num2[i], num1[i]);
				}
				printf("%d %d\n", num1[i] / temp, num2[i] / temp);
			}
		}
		else if (num1[i] == 0 && num2[i] != 0) { //上面次数小于下面次数,直接是0
			printf("0 1\n");
		}
		else if (num2[i] == 0) { //上面次数大于下面次数,是正无穷
			printf("infty\n");
		}
		T--;
	}
	return 0;
}

信息

递交者
类型
递交
题目
P1000 hitwh 2019 新生赛 A ∞
语言
C
递交时间
2020-12-21 20:35:13
评测时间
2020-12-21 20:35:13
评测机
分数
0
总耗时
0ms
峰值内存
0 Bytes