C語言解二元一次方程


#include <stdio.h>
#include <stdlib.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char *argv[]) 
{
    int a,b,c,d,x,y,z,z1;
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%ld",&z);
    printf("%d*x %d*y=%d",a,b,z);
    printf("\n");
    scanf("%d",&c);
    scanf("%d",&d);
    scanf("%ld",&z1);
    printf("%d*x %d*y=%d",a,b,z1);
    printf("\n");
    for(x=-1000;x<=1000;x++)
    {    
        for(y=-1000;y<=1000;y++)
        {
            if((a*x+b*y==z)&&(c*x+d*y==z1))
            {
                printf("x=%d,y=%d",x,y);
                printf("\n");
            }         
        }
    }
    return 0;
}
 
        

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM