By GokiSoft.com|
19:57 07/12/2021|
Lập Trình C
Bài tập - Giải hệ phương trình bậc nhất nhất 2 ẩn - Lập trình C
Giải hệ phương trình bậc nhất nhất 2 ẩn
a1x + b1y = c1
a2x + b2y = c2
Tags:
Phản hồi từ học viên
5
(Dựa trên đánh giá ngày hôm nay)
![Âu Duy Quyền [c_online]](https://www.gravatar.com/avatar/90ca555110a54024dd82b80fe75cf3ae.jpg?s=80&d=mm&r=g)
Âu Duy Quyền
2022-10-02 03:04:58
#include <stdio.h>
#include <stdlib.h>
/* Giai he pt bac nhat 2 an: a1x + b1y = c1
a2x + b2y = c2 */
int main(int argc, char *argv[]) {
int a1, b1, c1, a2, b2, c2, D, Dx, Dy, x, y;
printf("Giai he phuong trinh 2 an sau");
printf("\na1x + b1y = c1");
printf("\na2x + b2y = c2");
printf("\nNhap a1, b1, c1, a2, b2, c2 ");
scanf("%d%d%d%d%d%d", &a1, &b1, &c1, &a2, &b2, &c2);
D = a1*b2 - b1*a2;
Dx = b1*c2 - c1*b2;
Dy = a1*c2 - c1*a2;
if(D == 0) {
if(Dx == 0 && Dy == 0) {
printf("HPT co vo so nghiem");
} else {
printf("HPT vo nghiem");
}
} else {
x = Dx / D;
y = Dy / D;
printf("HPT co nghiem x = %d, y = %d", x, y);
}
return 0;
}
![An Văn Minh [T2008A]](https://www.gravatar.com/avatar/e0f14efe4b11f7d9d5901e8802319c92.jpg?s=80&d=mm&r=g)
An Văn Minh
2020-09-14 06:44:52
#include <stdio.h>
#include <math.h>
int main(int argc, char *argv[])
{
float a1,a2,b1,b2,c1,c2,x,y,D,Dx,Dy;
printf("Nhap he so a1=");
scanf("%f", &a1);
printf("Nhap he so b1=");
scanf("%f", &b1);
printf("Nhap he so c1=");
scanf("%f", &c1);
printf("Nhap he so a2=");
scanf("%f", &a2);
printf("Nhap he so b2=");
scanf("%f", &b2);
printf("Nhap he so c2=");
scanf("%f", &c2);
D = a1*b2-a2*b1;
Dx = c1*b2 -c2*b1;
Dy = a1*c2 - a2*c1;
if(D==0){
if(Dx==Dy){
printf("phuong trinh vo so nghiem");
}else{
printf("phuong trinh vo nghiem");
}
}else{
x = Dx/D;
y = Dy/D;
printf("phuong trinh co nghiem x,y = %f,%f", x,y);
}
return 0;
}
![Nguyễn Hữu Hiếu [T2008A]](https://www.gravatar.com/avatar/ca2884508b617fee77f000c7d99c219d.jpg?s=80&d=mm&r=g)
Nguyễn Hữu Hiếu
2020-09-14 05:11:59
#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[]) {
float a1,a2,b1,b2,c1,c2,d,dx,dy,x,y;
printf("\na1 = "); scanf("%f", &a1);
printf("\na2 = "); scanf("%f", &a2);
printf("\nb1 = "); scanf("%f", &b1);
printf("\nb2 = "); scanf("%f", &b2);
printf("\nc1 = "); scanf("%f", &c1);
printf("\nc2 = "); scanf("%f", &c2);
d = a1*b2 - a2*b1; dx = c1*b2 - c2*b1; dy = a1*c2 - a2*c1;
if (d == dx && d == dy && dy == 0) { printf("\nPT VSN"); }
if (d == 0) { printf("\nPT VN"); }
else {
x = dx/d; y = dy/d;printf("\nx = %f, \ny = %f", x, y);
}
return 0;
}
![Nguyễn Xuân Mai [T2008A]](https://www.gravatar.com/avatar/d3d863d6f47708501814fb41e9c38f31.jpg?s=80&d=mm&r=g)
Nguyễn Xuân Mai
2020-09-12 15:51:40
float a1,a2,b1,b2,c1,c2,x,y,D,Dx,Dy;
printf("\nNhap a1:");
scanf("%f",&a1);
printf("\nNhap a2:");
scanf("%f",&a2);
printf("\nNhap b1:");
scanf("%f",&b1);
printf("\nNhap b2:");
scanf("%f",&b2);
printf("\nNhap c1:");
scanf("%f",&c1);
printf("\nNhap c2:");
scanf("%f",&c2);
D = a1*b2-a2*b1;
Dx = c1*b2 -c2*b1;
Dy = a1*c2 - a2*c1;
if(D==0){
if(Dx==Dy){
printf("\npt vo so nghiem");
}else{
printf("\npt vo nghiem");
}
}else{
x = Dx/D;
y = Dy/D;
printf("\nNghiem x = %f, y = %f", x,y);
}
![Do Trung Duc [T2008A]](https://www.gravatar.com/avatar/2973ac07124f066b4605c535e8d39a99.jpg?s=80&d=mm&r=g)
Do Trung Duc
2020-09-12 14:03:16
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char *argv[]) {
float a1,a2,b1,b2,c1,c2,x,y,D,Dx,Dy;
printf("Nhap he so a1=");
scanf("%f", &a1);
printf("Nhap he so b1=");
scanf("%f", &b1);
printf("Nhap he so c1=");
scanf("%f", &c1);
printf("Nhap he so a2=");
scanf("%f", &a2);
printf("Nhap he so b2=");
scanf("%f", &b2);
printf("Nhap he so c2=");
scanf("%f", &c2);
D = a1*b2-a2*b1;
Dx = c1*b2 -c2*b1;
Dy = a1*c2 - a2*c1;
if(D==0){
if(Dx==Dy){
printf("phuong trinh vo so nghiem");
}else{
printf("phuong trinh vo nghiem");
}
}else{
x = Dx/D;
y = Dy/D;
printf("phuong trinh co nghiem x,y = %f,%f", x,y);
}
return 0;
}
![Trần Thị Khánh Huyền [T2008A]](https://www.gravatar.com/avatar/554e115833778e4294a01aebe228f3d6.jpg?s=80&d=mm&r=g)
Trần Thị Khánh Huyền
2020-09-12 13:31:11
#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[]) {
float a1, b1, c1, a2, b2, c2,x , y;
printf("Nhap gia tri a1 ="); scanf("%f", &a1);
printf("Nhap gia tri a2 ="); scanf("%f", &a2);
printf("Nhap gia tri b1 ="); scanf("%f", &b1);
printf("Nhap gia tri b2 ="); scanf("%f", &b2);
printf("Nhap gia tri c1 ="); scanf("%f", &c1);
printf("Nhap gia tri c2 ="); scanf("%f", &c2);
float D, Dx, Dy;
D = a1*b2-b1*a2;
Dx = c1*b2-b1*c2;
Dy = a1*c2-c1*a2;
if (D!=0){
x=Dx/D;
y=Dy/D;
printf ("\nHe phuong trinh co nghiem x=%f",x);
printf ("\nHe phuong trinh co nghiem y=%f",y);}
else {if (Dx==0 &&Dy==0) {printf("PTVSN");}
else{printf("PTVN");
}}
return 0;
}
![Nguyễn Anh Vũ [T2008A]](https://www.gravatar.com/avatar/8863d24ed74b396082becbc4db8331fd.jpg?s=80&d=mm&r=g)
Nguyễn Anh Vũ
2020-09-12 13:10:35
#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[]) {
//bat dau code;
int a1, a2, b1, b2, c1, c2;
float d, dx, dy, x, y;
printf("a1*x+b1*y=c1");
printf("\nNhap gia tri cua a1 =");
scanf("%d, &a1");
printf("\nNhap gia tri cua b1 =");
scanf("%d, &b1");
printf("\nNhap gia tri cua c1 =");
scanf("%d, &c1");
printf("a2*x+b2*y=c2");
printf("\nNhap gia tri cua a2 =");
scanf("%d, &a2");
printf("\nNhap gia tri cua b2 =");
scanf("%d, &b2");
printf("\nNhap gia tri cua c2 =");
scanf("%d, &c2");
d=a1*b2-a1*b1;
dx=c1*b2-c2*b1;
dy=a1*c2-a2*c1;
if(d==0){
if(dx+dy==0)
printf("\nHe phuong trinh vo so nghiem");
}
printf("\nHe phuong trinh vo nghiem");
x = dx / d;
y = dy / d;
printf("\nPhuong trinh có 2 nghiem x,y = %d%d",x,y);
//ket thuc code;
return 0;
}
![Trần Văn Lâm [T2008A]](https://www.gravatar.com/avatar/cfc15c8cb7781ad669b013e01f9f1a6b.jpg?s=80&d=mm&r=g)
Trần Văn Lâm
2020-09-12 06:48:30
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 a1, b1, c1, a2, b2, c2;
float D, Dx, Dy, x, y;
printf("a1*x + b1*y = c1\n");
printf("a2*x + b2*y = c2\n");
printf("\nnhap a1: ");
scanf("%d", &a1);
printf("\nnhap b1: ");
scanf("%d", &b1);
printf("\nnhap c1: ");
scanf("%d", &c1);
printf("\nnhap a2: ");
scanf("%d", &a2);
printf("\nnhap b2: ");
scanf("%d", &b2);
printf("\nnhap c2: ");
scanf("%d", &c2);
D = a1*b2 - a2*b1;
Dx = c1*b2 - c2*b1;
Dy = a1*c2 - a2*c1;
if(D==0) {
if(Dx + Dy ==s 0);
printf("He phuong trinh co vo so nghiem");
printf("He phuong trinh vo nghiem");
}
{
x = Dx / D;
y = Dy / D;
printf("He phuong trinh co nghiem x,y");
scanf("%d%d", &x, &y);
}
return 0;
}
![nguyễn Sử [T2008A]](https://www.gravatar.com/avatar/47487be2776ac2ec915b0936ef7ab5ae.jpg?s=80&d=mm&r=g)
nguyễn Sử
2020-09-11 13:23:13
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[]) {
int a1, b1, c1, a2, b2, c2;
float d, dx, dy, x, y;
printf(" giai he phuong trinh bac nhat 2 an /n ");
printf("\nGia tri a1 = ");
scanf("%d, &a1");
printf("\nGia tri b1 = ");
scanf("%d, &b1");
printf("\nGia tri c1 = ");
scanf("%d, &c1");
printf("\nGia tri a2 = ");
scanf("%d, &a2");
printf("\nGia tri b2 = ");
scanf("%d, &b2");
printf("\nGia tri c2 = ");
scanf("%d, &c2");
D = a1*b2 - a2*b1;
Dx = c1*b2 - c2*b1;
Dy = a1*c2 - a2*1;
if (D == 0) {
if (Dx + Dy == 0)
printf("He phuong trinh co vo so nghiem");
else
printf("He phuong trinh vo nghiem");
}
else {
x = Dx / D;
y = Dy / D;
printf("He phuong trinh co nghiem (x, y) = (%d, %d)", x, y);
}
return 0;
}
![vuong huu phu [T2008A]](https://www.gravatar.com/avatar/307a5cf29780afab49706dc8b15b86c6.jpg?s=80&d=mm&r=g)
vuong huu phu
2020-09-11 13:06:26
#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 a1,a2,b1,b2,c1,c2;
float d,dx,dy,x,y;
printf("\nNhap gia tri cua a1 = ");
scanf("%d",&a1);
printf("\nNhap gia tri cua a2 = ");
scanf("%d",&a2);
printf("\nNhap gia tri cua b1= ");
scanf("%d",&b1);
printf("\nNhap gia tri cua b2 = ");
scanf("%d",&b2);
printf("\nNhap gia tri cua c1 = ");
scanf("%d",&c1);
printf("\nNhap gia tri cua c2 = ");
scanf("%d",&c2);
d=a1*b2-a2*b1;
dx=c1*b2-c2*b1;
dy=a1*c2-a2*c1;
if(d==0) {
if(dx+dy==0)
printf("\n pt co vo so nghiem");
else
printf("\n pt vo nghiem");
}
else{
x = dx / d;
y = dy / d;
printf("\n pt co nghiem (x,y) = (%d,%d)",x,y);
}
return 0;
}