Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<cmath>
- using namespace std;
- double hitungGradien(int y2, int y1, int x2, int x1){
- return (double) (y2-y1) / (x2-x1);
- }
- int main(){
- int N;
- int x[2500];
- int y[2500];
- int numberOfGradient;
- double m[2500];
- int count;
- cin>>N;
- for(int i=0; i<N; i++){
- cin>>x[i]>>y[i];
- }
- cout<<endl;
- numberOfGradient = 0;
- for(int i=0; i<N; i++){
- for(int j=N-1; j>i; j--){
- //cout<<x[i]<<","<<y[i]<<endl;
- //cout<<x[j]<<","<<y[j]<<endl;
- m[numberOfGradient] = abs(hitungGradien(y[j],y[i],x[j],x[i]));
- numberOfGradient++;
- }
- }
- //cout<<numberOfGradient;
- for(int k=0; k<numberOfGradient; k++){
- cout<<k<<" = "<<m[k]<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement