DIỄN ĐÀN CÔNG NGHỆ THÔNG TIN _ GIẢI TRÍ TINK5UNETI.TK & TINK5UNETI.FORUMVI.COM
 
Input/output matrix Tttttt13Trang ChínhLatest imagesTìm kiếmVườn ước nguyệnInput/output matrix Game10Đăng kýĐăng Nhập


Xem chủ đề cũ hơnXem chủ đề mới hơnGo down
Input/output matrix Collap10 Input/output matrix EmptyThời gian: Input/output matrix Icon_minitimeFri Dec 23, 2011 11:58 pm


HạnhPhúcẢo
HạnhPhúcẢo
Tước hiệuDÂN THƯỜNG
DÂN THƯỜNG
Birthday : 24/11/1992
NGHỀ NGHIỆP : SV
Đến từ : Lào Cai
Posts : 32
Points : 22700
Age : 31
Tham gia : 18/12/2011
Level: 32 Kinh nghiệm: 31%
Sinh mệnh: 32/100
Pháp lực: 31/100
Birthday : 24/11/1992
NGHỀ NGHIỆP : SV
Đến từ : Lào Cai
Posts : 32
Points : 22700
Age : 31
Tham gia : 18/12/2011

Input/output matrix Vide

Bài gửiTiêu đề: Input/output matrix

Nhập, xuất ma trận sử dụng con trỏ
Code:

#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
void main()
{
clrscr();
float a[1][1],*p;
int i,j,m,n;

p=(float*)a;
cout<<"Enter your Nunber of Row and Colums: ";
cin>>m>>n;
if((m==0&&n==1)||(m==1&&n==0))
   {
      cout<<"Note ! your matrix only 1 value,please sure you type it correct.."<<endl;
      //break;
   }
else
   {
      if(m==1&&n==1)
         {
            cout<<"Note ! your matrix only have 1 value. Please sure you type it correct.."<<endl;
            //break;
         }
      else       cout<<"Your matrix have "<<m*n<<" value."<<endl;
}

p=new float(m*n);//Allocate memory for this array,if you don't allocate memory,it'll be overlow memory
cout<<"\nEnter value for this matrix: ";


for(i=0;i<m*n;i++)
{
cout<<"a["<<i/n<<"]["<<i%n<<"]="<<endl;
cin>>*(p+i);
}
cout<<"Your matrix is: "<<endl;
for(i=0;i<m;i++)
{
for(j=0;j<n;j++) cout<<setw(4)/*set position of column*/<<*(p+n*i+j)<<" ";
cout<<endl;

}

delete p;//Delete your memory which was allocated by system
getch();
}
Input/output matrix 1_0110 Input/output matrix 1_02-110 Input/output matrix 1_0310
Input/output matrix 1_0410
Input/output matrix Empty
Input/output matrix 1_0610
Input/output matrix 1_0410
Input/output matrix 1_0710 Input/output matrix 1_0810 Input/output matrix 1_0910
Tài Sản của HạnhPhúcẢo

Bài viết mới cùng chuyên mục

Bài viết liên quan

Input/output matrix

Xem chủ đề cũ hơn Xem chủ đề mới hơn Về Đầu Trang
Trang 1 trong tổng số 1 trang



Permissions in this forum:Bạn không có quyền trả lời bài viết
TIN K5 UNETI :: HỌC TẬP :: TRAO ĐỔI HỌC TẬP-
Free forum | ©phpBB | Free forum support | Báo cáo lạm dụng | Thảo luận mới nhất