forked from gongyiling/cpp_lecture
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherror.cpp
More file actions
26 lines (22 loc) · 521 Bytes
/
error.cpp
File metadata and controls
26 lines (22 loc) · 521 Bytes
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
#include <stdio.h>
#include <stdint.h>
float det(float a, float b, float c ,float d)
{
return a * d - b * c;
}
int main()
{
float M[2][2] = {{1.0, 1.0}, {1.0, 1.0}};
float c[2] = {1.0, 1.0};
uint32_t& u10 = *(uint32_t*)&M[1][0];
for (int i = 0; i < 100; i++)
{
float d = det(M[0][0], M[0][1], M[1][0], M[1][1]);
float x = det(c[0], M[0][1], c[1], M[1][1]) / d;
float y = det(M[0][0], c[0], M[1][0], c[1]) / d;
printf("det=%e\tx=%e\ty=%e\n", d, x, y);
u10--;
M[1][1] = 2 - M[1][0];
}
return 0;
}