- 输油管道问题
- 2015-05-09 12:36:24 @
难道std大法失效?蒟蒻求解
foo.cpp: In function 'int main()':
foo.cpp:13:17: error: 'sort' was not declared in this scope
sort(a[2],a[2]+n);
^
3 条评论
-
CWW LV 8 @ 2015-05-16 10:27:35
为什么本地编译可过,求解?
-
2015-05-11 17:01:02@
import java.io.*;
import java.util.*;public class Main
{public static void main(String[] args)
{
// TODO Auto-generated method stub
Scanner input = new Scanner(System.in);
int n = input.nextInt();
int a[] = new int[n];
for (int i = 0; i < n; i++)
{
input.nextInt();
a[i] = input.nextInt();
}
Arrays.sort(a);
int ans = 0;
for (int i = 0; i < n; i++)
{
ans += Math.abs(a[i] - a[n / 2]);
}
System.out.println(ans);
}}
-
2015-05-09 15:55:00@
sort() 需要
#include <algorithm>
- 1