bÀi tẬp ngÔn ngỮ lẬp trÌnh

23
BÀI TẬP NGÔN NGỮ LẬP TRÌNH 2.Bài tập phần các thành phần cơ bản Giải phương trình bậc 2: #include<iostream> #include<conio.h> #include<stdio.h> #include<math.h> using namespace std; int main() { double a,b,c,x1,x2; do { cout<<"nhap a : ";cin>>a; cout<<"nhap b : ";cin>>b; cout<<"nhap c : ";cin>>c; } while(a==0); double d=b*b-4*a*c; a=(2*a);d=sqrt(d); if(d>=0) { if(d>0) { cout<<"phuong trinh co 2 nghiem phan biet :"<<"x1="<<(-b-d)/a<<",x2="<<(-b+d)/a<<endl; } else cout<<"puong trinh co nghiem kep : "<<"x1 = x2 = "<<(-b/a)<<endl; } else cout<<"phuong trinh vo nghiem"<<endl; system("pause"); return 1; } 3.Bài tập phần biểu thức và toán tử 3.1.Viết chương trình in ra màn hình các giá trị từ 1 đến k dưới dạng ma trận m*n với k=m*n được khởi tạo từ hàm mian(): #include<iostream>

Upload: anystars

Post on 19-Oct-2015

18 views

Category:

Documents


1 download

DESCRIPTION

Chuong5

TRANSCRIPT

BI TP NGN NG LP TRNH2.Bi tp phn cc thnh phn c bnGii phng trnh bc 2:#include#include#include#includeusing namespace std;int main(){double a,b,c,x1,x2;do{couta;coutb;coutc;}while(a==0);double d=b*b-4*a*c;a=(2*a);d=sqrt(d);if(d>=0){if(d>0){cout