Language: Java

#include<bits/stdc++.h>
using namespace std;

struct CWW{
    CWW(){
        cin.tie(0);
        ios_base::sync_with_stdio(0);
        cout<<fixed<<setprecision(15);
    }
}STAR;

using D=double;

const D EPS=1e-8;
const D INF=1e9;

const int COUNTER_CLOCKWISE=1;
const int CLOCKWISE=-1;
const int ONLINE_FRONT=2;
const int ONLINE_BACK=-2;
const int ON_SEGMENT=0;

using Point=complex<D>;

struct Segment{
    Point p1,p2;
    Segment(const Point &p1=Point(),const Point &p2=Point()):p1(p1),p2(p2){}
};

struct Line{
    Point p1,p2;
    Line(const Point &p1=Point(),const Point &p2=Point()):p1(p1),p2(p2){}
};

struct Circle{
    Point c;
    D r;
    Circle(const Point &c=Point(),const D &r=0.0):c(c),r(r){}
};

using Polygon=vector<Point>;

#define EQ(a,b) (abs((a)-(b))<EPS)

istream& operator>>(istream &is,Point &a){
    D x,y;
    is>>x>>y;
    a=Point(x,y);
    return is;
}

ostream& operator<<(ostream& os,const Point &a){
    os<<real(a)<<" "<<imag(a);
    return os;
}

istream& operator>>(istream &is,Line &l){
    Point p1,p2;
    is>>p1>>p2;
    l=Line(p1,p2);
    return is;
}

istream& operator>>(istream &is,Segment &s){
    Point p1,p2;
    is>>p1>>p2;
    s=Segment(p1,p2);
    return is;
}

D dot(const Point &a,const Point &b){
    return real(a)*real(b)+imag(a)*imag(b);
}

D cross(const Point &a,const Point &b){
    return real(a)*imag(b)-imag(a)*real(b);
}

Point projection(const Point &a,const Point &b){
    return a*real(b/a);
}

Point projection(const Line &l,const Point &a){
    return l.p1+projection(l.p2-l.p1,a-l.p1);
}

Point reflection(const Line &l,const Point &a){
    Point p=projection(l,a);
    return 2.0*p-a;
}

int ccw(Point a,Point b,Point c){
    b-=a;c-=a;
    if(cross(b,c)>EPS)return COUNTER_CLOCKWISE;
    if(cross(b,c)<-EPS)return CLOCKWISE;
    if(dot(b,c)<-EPS)return ONLINE_BACK;
    if(norm(b)+EPS<norm(c))return ONLINE_FRONT;
    return ON_SEGMENT;
}

bool isOrthogonal(const Point &a,const Point &b){
    return EQ(dot(a,b),0.0);
}

bool isOrthogonal(const Point &a1,const Point &a2,const Point &b1,const Point &b2){
    return isOrthogonal(a2-a1,b2-b1);
}

bool isOrthogonal(const Line &l,const Line &m){
    return isOrthogonal(l.p1,l.p2,m.p1,m.p2);
}

bool isParallel(const Point &a,const Point &b){
    return EQ(cross(a,b),0.0);
}

bool isParallel(const Point &a1,const Point &a2,const Point &b1,const Point &b2){
    return isParallel(a1-a2,b1-b2);
}

bool isParallel(const Line &l,const Line &m){
    return isParallel(l.p1,l.p2,m.p1,m.p2);
}

bool intersect(const Point &a1,const Point &a2,const Point &b1,const Point &b2){
    return ccw(a1,a2,b1)*ccw(a1,a2,b2)<=0&&
            ccw(b1,b2,a1)*ccw(b1,b2,a2)<=0;
}

bool intersect(Segment &s,Segment &t){
    return intersect(s.p1,s.p2,t.p1,t.p2);
}

Point crossPoint(const Segment &s1,const Segment &s2){
    Point  base=s2.p2-s2.p1;
    D d1=abs(cross(base,s1.p1-s2.p1));
    D d2=abs(cross(base,s1.p2-s2.p1));

    D t=d1/(d1+d2);
    return s1.p1+(s1.p2-s1.p1)*t;
}



int main(){
    int Q;cin>>Q;
    while(Q--){
        Segment s,t;
    cin>>s>>t;
    cout<<crossPoint(s,t)<<endl;
    }
    return 0;
}

Compiler output:
Main.java:1: error: illegal character: '#'
#include<bits/stdc++.h>
^
Main.java:1: error: class, interface, enum, or record expected
#include<bits/stdc++.h>
        ^
Main.java:4: error: class, interface, enum, or record expected
struct CWW{
^
Main.java:7: error: class, interface, enum, or record expected
        ios_base::sync_with_stdio(0);
        ^
Main.java:8: error: class, interface, enum, or record expected
        cout<<fixed<<setprecision(15);
        ^
Main.java:9: error: class, interface, enum, or record expected
    }
    ^
Main.java:12: error: unnamed classes are a preview feature and are disabled by default.
using D=double;
^
  (use --enable-preview to enable unnamed classes)
Main.java:12: error: '.class' expected
using D=double;
              ^
Main.java:14: error: class, interface, enum, or record expected
const D EPS=1e-8;
^
Main.java:15: error: class, interface, enum, or record expected
const D INF=1e9;
^
Main.java:17: error: class, interface, enum, or record expected
const int COUNTER_CLOCKWISE=1;
^
Main.java:18: error: class, interface, enum, or record expected
const int CLOCKWISE=-1;
^
Main.java:19: error: class, interface, enum, or record expected
const int ONLINE_FRONT=2;
^
Main.java:20: error: class, interface, enum, or record expected
const int ONLINE_BACK=-2;
^
Main.java:21: error: class, interface, enum, or record expected
const int ON_SEGMENT=0;
^
Main.java:23: error: illegal start of expression
using Point=complex<D>;
                      ^
Main.java:25: error: class, interface, enum, or record expected
struct Segment{
^
Main.java:27: error: class, interface, enum, or record expected
    Segment(const Point &p1=Point(),const Point &p2=Point()):p1(p1),p2(p2){}
    ^
Main.java:30: error: class, interface, enum, or record expected
struct Line{
^
Main.java:32: error: class, interface, enum, or record expected
    Line(const Point &p1=Point(),const Point &p2=Point()):p1(p1),p2(p2){}
    ^
Main.java:35: error: class, interface, enum, or record expected
struct Circle{
^
Main.java:38: error: class, interface, enum, or record expected
    Circle(const Point &c=Point(),const D &r=0.0):c(c),r(r){}
    ^
Main.java:43: error: illegal character: '#'
#define EQ(a,b) (abs((a)-(b))<EPS)
^
Main.java:43: error: class, interface, enum, or record expected
#define EQ(a,b) (abs((a)-(b))<EPS)
        ^
Main.java:47: error: class, interface, enum, or record expected
    is>>x>>y;
    ^
Main.java:48: error: class, interface, enum, or record expected
    a=Point(x,y);
    ^
Main.java:49: error: class, interface, enum, or record expected
    return is;
    ^
Main.java:50: error: class, interface, enum, or record expected
}
^
Main.java:54: error: class, interface, enum, or record expected
    return os;
    ^
Main.java:55: error: class, interface, enum, or record expected
}
^
Main.java:59: error: class, interface, enum, or record expected
    is>>p1>>p2;
    ^
Main.java:60: error: class, interface, enum, or record expected
    l=Line(p1,p2);
    ^
Main.java:61: error: class, interface, enum, or record expected
    return is;
    ^
Main.java:62: error: class, interface, enum, or record expected
}
^
Main.java:66: error: class, interface, enum, or record expected
    is>>p1>>p2;
    ^
Main.java:67: error: class, interface, enum, or record expected
    s=Segment(p1,p2);
    ^
Main.java:68: error: class, interface, enum, or record expected
    return is;
    ^
Main.java:69: error: class, interface, enum, or record expected
}
^
Main.java:73: error: class, interface, enum, or record expected
}
^
Main.java:77: error: class, interface, enum, or record expected
}
^
Main.java:81: error: class, interface, enum, or record expected
}
^
Main.java:85: error: class, interface, enum, or record expected
}
^
Main.java:89: error: class, interface, enum, or record expected
    return 2.0*p-a;
    ^
Main.java:90: error: class, interface, enum, or record expected
}
^
Main.java:93: error: class, interface, enum, or record expected
    b-=a;c-=a;
         ^
Main.java:94: error: class, interface, enum, or record expected
    if(cross(b,c)>EPS)return COUNTER_CLOCKWISE;
    ^
Main.java:95: error: class, interface, enum, or record expected
    if(cross(b,c)<-EPS)return CLOCKWISE;
    ^
Main.java:96: error: class, interface, enum, or record expected
    if(dot(b,c)<-EPS)return ONLINE_BACK;
    ^
Main.java:97: error: class, interface, enum, or record expected
    if(norm(b)+EPS<norm(c))return ONLINE_FRONT;
    ^
Main.java:98: error: class, interface, enum, or record expected
    return ON_SEGMENT;
    ^
Main.java:99: error: class, interface, enum, or record expected
}
^
Main.java:103: error: class, interface, enum, or record expected
}
^
Main.java:107: error: class, interface, enum, or record expected
}
^
Main.java:111: error: class, interface, enum, or record expected
}
^
Main.java:115: error: class, interface, enum, or record expected
}
^
Main.java:119: error: class, interface, enum, or record expected
}
^
Main.java:123: error: class, interface, enum, or record expected
}
^
Main.java:128: error: class, interface, enum, or record expected
}
^
Main.java:132: error: class, interface, enum, or record expected
}
^
Main.java:140: error: class, interface, enum, or record expected
    return s1.p1+(s1.p2-s1.p1)*t;
    ^
Main.java:141: error: class, interface, enum, or record expected
}
^
Main.java:146: error: class, interface, enum, or record expected
    int Q;cin>>Q;
          ^
Main.java:147: error: class, interface, enum, or record expected
    while(Q--){
    ^
Main.java:149: error: class, interface, enum, or record expected
    cin>>s>>t;
    ^
Main.java:150: error: class, interface, enum, or record expected
    cout<<crossPoint(s,t)<<endl;
    ^
Main.java:151: error: class, interface, enum, or record expected
    }
    ^
Main.java:153: error: class, interface, enum, or record expected
}
^
67 errors