程序纠正,帮忙看怎么改,谢谢!
我想要的和出来的...
求大神更改
以下是代码:
程序代码:
#include <stdio.h> #include <math.h> int main( void ) { int c, r; int x, y; float xmin, ymin, xmax, ymax; float x1, y1, x2, y2, x3, y3; float x0, y0; float m1, m2, m3; printf("Enter c and r: "); scanf("%d %d", &r,&c); printf("Enter xmin, ymin: "); scanf("%f %f", &xmin, &ymin); printf("Enter xmax, ymax: "); scanf("%f %f", &xmax, &ymax); printf("Enter x1, y1, x2, y2, x3, y3: "); scanf("%f %f %f %f %f %f", &x1, &y1, &x2, &y2, &x3, &y3); for(x = 0; x <= c + 1; x++) { for(y = 0; y <= r + 1; y++) { x0 = ((xmax - xmin) / c) * (c - x) + xmin; y0 = ((ymax - ymin) / r) * (y - 1) + ymin; m1 = ((y3 - y1) / (x3 -x1)) * (x0 - x3) + y3; m2 = ((y3 - y2) / (x3 -x2)) * (x0 - x2) + y2; m3 = ((y1 - y2) / (x1 -x2)) * (x0 - x1) + y1; if(((x == 0) && (y == 0)) || ((x == c + 1) && (y == 0)) || ((x == 0) && (y == r + 1)) || ((x == c + 1) && (y == r + 1))) { printf("+"); } else if((x == 0) || (x == c + 1)){ printf("-"); } else if((y == 0) || (y == r + 1)){ printf("|"); } else if((y0 >= m1) && (y0 <= m2) && (y0 >= m3)){ printf("*"); } else{ printf(" "); } } printf("\n"); } return 0; }
我要用什么办法才能输出来和左边那个图一模一样的??
[ 本帖最后由 cyy06180521 于 2015-8-28 16:20 编辑 ]