|
|
Регистрация Восстановить пароль |
Повторная активизация e-mail |
Регистрация | Задать вопрос |
Заплачу за решение |
Новые сообщения |
Сообщения за день |
Расширенный поиск |
Правила |
Всё прочитано |
|
Опции темы | Поиск в этой теме |
09.05.2014, 17:09 | #1 |
Новичок
Джуниор
Регистрация: 09.05.2014
Сообщений: 1
|
Помогите,пожалуйста!
Я новичок в пользовании С++. Не могу сделать курсовую до конца.
Задание с матрицами и таблицами. У меня есть две матрицы (пользователь сам ставит размерность и вводит данные), после работы с ними выскакивает третея матрица (результат), этот результат нужно перевести в таблицу (только после нажатия определенной кнопки). Помогите пожалуйста решить проблему...Вот код программы.:conf used: #include <vcl.h> #pragma hdrstop #include "Unit1.h" #include "Unit2.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TForm1 *Form1; bool nay1=0,nay2=0,res1=0; int s; TStringList *F; class Matrix {public: int row, col; int **A; void SetMatrix (int r,int c) { row=r; col=c; A=new int*[r]; for (int i=0;i<r;i++) A[i]=new int[c]; for (int i=0;i<r;i++) for (int j=0;j<c;j++) A[i][j]=0;} Matrix Add(Matrix B) { Matrix C; C.row=row; C.col=col; C.SetMatrix(C.row,C.col); for (int i=0;i<C.row;i++) for (int j=0;j<C.col;j++) C.A[i][j]=A[i][j]+B.A[i][j]; return C;} Matrix Subtr(Matrix B) { Matrix C; C.row=row; C.col=col; C.SetMatrix(C.row,C.col); for (int i=0;i<C.row;i++) for (int j=0;j<C.col;j++) C.A[i][j]=A[i][j]-B.A[i][j]; return C;} Matrix PrNum(double a) { Matrix C; C.row=row; C.col=col; C.SetMatrix(C.row,C.col); for (int i=0;i<C.row;i++) for (int j=0;j<C.col;j++) C.A[i][j]=A[i][j]*a; return C;} Matrix Trans() { Matrix C; C.row=col; C.col=row; C.SetMatrix(C.row,C.col); for (int i=0;i<C.row;i++) for (int j=0;j<C.col;j++) C.A[i][j]=A[j][i]; return C;} Matrix PrMat(Matrix B) { Matrix C; int k=0; C.row=row; C.col=row; C.SetMatrix(C.row,C.col); for (int i=0;i<row;i++) for (int j=0;j<row;j++) { for (int s=0;s<col;s++) k=k+A[i][s]*B.A[s][j]; C.A[i][j]=k; k=0; } return C; } }A1,A2,B1,B2; void __fastcall TForm1::Button1Click(TObject *Sender) { nay1=1; StringGrid1->ColCount=ComboBox2->ItemIndex+1; StringGrid1->RowCount=ComboBox1->ItemIndex+1; // changing of size of StringGrid StringGrid1->Width =(ComboBox2->ItemIndex+1)*35+2+(ComboBox2->ItemIndex+1); // StringGrid1->Height=(ComboBox1->ItemIndex+1)*30+2+(ComboBox1->ItemIndex+1); // StringGrid1->Visible=true; Panel1->Visible=false; for(int i=0;i<ComboBox1->ItemIndex+1;i++) for(int j=0;j<ComboBox2->ItemIndex+1;j++) StringGrid1->Cells[j][i]=0; } void __fastcall TForm1::Button2Click(TObject *Sender) { nay2=1; StringGrid2->ColCount=ComboBox4->ItemIndex+1; StringGrid2->RowCount=ComboBox3->ItemIndex+1; StringGrid2->Width =(ComboBox4->ItemIndex+1)*35+2+(ComboBox4->ItemIndex+1); StringGrid2->Height=(ComboBox3->ItemIndex+1)*30+2+(ComboBox3->ItemIndex+1); StringGrid2->Visible=true; Panel2->Visible=false; for(int i=0;i<ComboBox3->ItemIndex+1;i++) for(int j=0;j<ComboBox4->ItemIndex+1;j++) StringGrid2->Cells[j][i]=0; } void __fastcall TForm1::MenuItem2Click(TObject *Sender) { for(int i=0;i<StringGrid2->ColCount;i++) for(int j=0;j<StringGrid2->RowCount;j++) StringGrid2->Cells[i][j]=""; } void __fastcall TForm1::MenuItem1Click(TObject *Sender) { for(int i=0;i<StringGrid2->ColCount;i++) for(int j=0;j<StringGrid2->RowCount;j++) StringGrid2->Cells[i][j]=""; StringGrid2->Visible=false; Label4->Visible=false; nay2=0; } void __fastcall TForm1::Close1Click(TObject *Sender) { for(int i=0;i<StringGrid1->ColCount;i++) for(int j=0;j<StringGrid1->RowCount;j++) StringGrid1->Cells[i][j]=""; StringGrid1->Visible=false; Label4->Visible=false; nay1=0; for(int i=0;i<StringGrid2->ColCount;i++) for(int j=0;j<StringGrid2->RowCount;j++) StringGrid2->Cells[i][j]=""; StringGrid2->Visible=false; Label3->Visible=false; nay2=0; for(int i=0;i<StringGrid3->ColCount;i++) for(int j=0;j<StringGrid3->RowCount;j++) StringGrid3->Cells[i][j]=""; StringGrid3->Visible=false; Label6->Visible=false; res1=0; Form1->Caption="Матриці "; } |
Похожие темы | ||||
Тема | Автор | Раздел | Ответов | Последнее сообщение |
Помогите создать програму для роботы с файлами, пожалуйста помогите нужно очень срочно | Сергей Человек | Фриланс | 3 | 06.07.2009 19:30 |
Помогите Помогите Пожалуйста Решить Одну Задачку в Паскале!!! | VisTBacK | Помощь студентам | 6 | 19.09.2008 13:44 |