标签:math tip ips float str stream input cin mat
#include<vector> #include<iostream> #include<math.h> using namespace std; int main() { int n;//元素个数 cin>>n;//输入n vector <int> a;//a[] int min=10000; for(int i=0;i<n;i++)//input n ints { int x; cin>>x; for(int j=0;j<i;j++) { if(abs(x-a[j])<min) min=abs(x-a[j]); } a.push_back(x); } cout<<min; return 0; }
Tips:
取绝对对值函数:
#include<cmath>
or
#include<math.h>
abs(int){
...
return int;
}
fabs(float)
...
标签:math tip ips float str stream input cin mat
原文地址:https://www.cnblogs.com/WuDie/p/11318125.html