aboutsummaryrefslogtreecommitdiff
path: root/rcc-legacy/tests/sysy_lvX/052_itera_sqrt.sy
blob: 1b970d14e25a72c102db2302b0b61c7a9b7978dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
int fsqrt(int a)
{
    int x0=0;
    int x1;
    x1=a/2;
    while(x0-x1!=0)
    {
        x0=x1;
        x1=(x0+a/x0);
        x1=x1/2;
    }

    return x1;

}

int main()
{
    int a;
    a=400;
    int res;
    res=fsqrt(a);
    putint(res);
    res = 10;
    putch(res);
    return 0;
}