Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 196389 Details for
Bug 276146
Incorrect code generation with sys-devel/gcc-4.3.2-r3
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
an amusing bug
math-test.c (text/plain), 1.25 KB, created by
Rafał Mużyło
on 2009-07-02 17:35:51 UTC
(
hide
)
Description:
an amusing bug
Filename:
MIME Type:
Creator:
Rafał Mużyło
Created:
2009-07-02 17:35:51 UTC
Size:
1.25 KB
patch
obsolete
>#include <stdio.h> > >static int gcd(int a, int b) { > int r; > if (a < 0) > a = -a; > if (b < 0) > b = -b; > while (b != 0) { > r = a%b; > a = b; > b = r; > } > return a; >} > >int main(void) { > int tc, cs; > int x0, y0, x1, y1, dx, dy; > int n, i; > int l; > int area; > > scanf("%d", &tc); > for (cs = 0; cs != tc; ++cs) { > scanf("%d", &n); > > x0 = 0; y0 = 0; > x1 = 0; y1 = 0; > l = 0; > area = 0; > for (i = 0; i != n; ++i) { > scanf("%d%d", &dx, &dy); > l+= gcd(dx, dy); > x1 = x0 + dx; > y1 = y0 + dy; > //printf("%d\n", x0*y1-x1*y0 ); > area += x0*y1-x1*y0; > //area += (x0*(y0+dy) - (x0+dx)*y0); > x0 = x1; y0 = y1; > } > if (area < 0) > area = -area; > > printf("Scenario #%d:\n", cs+1); > printf("%d %d %d.%d\n\n", (area+2-l)/2, l, area/2, area&1 ? 5 : >0); > } > > return 0; >} >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 276146
:
196387
| 196389