Question about Intel Compilers & Programming Tools

1 Answer

How to make program of finfing the determinant of m*n matrix in C coding

Posted by on

1 Answer

  • Level 2:

    An expert who has achieved level 2 by getting 100 points

    MVP:

    An expert that gotĀ 5 achievements.

    Vice President:

    An expert whose answer gotĀ voted for 100 times.

    Sniper:

    An expert who has posted more than 50 answers, of which 90% or more were rated as helpful.

  • Expert
  • 81 Answers

I solve your problem but there is a little mistake that I can't find but maybe you can so here what I wrote:

#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <dos.h>
#include <math.h>

#define n 3

typedef struct
{
double A[n][n];
int size;
}Matrix;

double det(Matrix mat);
Matrix cut(Matrix mat, int x);
int main(void)
{
clrscr();
double d;
Matrix mat;
mat.size=n;
mat.A[0][0]=1;
mat.A[0][1]=2;
mat.A[0][2]=3;
mat.A[1][0]=4;
mat.A[1][1]=4;
mat.A[1][2]=6;
mat.A[2][0]=7;
mat.A[2][1]=8;
mat.A[2][2]=9;

d=det(mat);
printf("%d",d);
getch();
return 0;
}
double det(Matrix mat)
{
double d=0;
if(mat.size>2)

for(int i=0;i<mat.size;i++)

d+=pow(-1,i)*mat.A[0][i]*det(cut(mat,i));

else

d=mat.A[0][0]*mat.A[1][1]-mat.A[0][1]*mat.A[1][0];

return d;
}
Matrix cut(Matrix mat, int x)
{
Matrix cutmat;
cutmat.size=mat.size-1;
for(int i=0;i<cutmat.size;i++)
for(int j=0;j<cutmat.size;j++)
if(j<x)
cutmat.A[i][j]=mat.A[i+1][j];
else
cutmat.A[i][j]=mat.A[i+1][j+1];
return cutmat;
}
Rate me if it helped!
And if you find the mistake please tell me where thanks.

Posted on Jul 07, 2009

Add Your Answer

Uploading: 0%

my-video-file.mp4

Complete. Click "Add" to insert your video. Add

×

Loading...
Loading...

Related Questions:

1 Answer

Wanted to do a good project on java.suggest d


if u have hardware knowledge,then u can interface a 4x4 matrix keypad with printer port and make a calculator!!
i have done this project, if u need hardware assistance tell me

Jul 14, 2010 | Sun Java Programming Language (cdj-275)

2 Answers

C++ poker program


Hi.

I suggest creating an Array of Cards (cardOne,cardTwo,etc. to five)

If you can enter them in one at a time, after declaring the array, assign the values to the array.

cin < cardOne; (Psuedo code by the way, hope you don't mind)

Afterwards, you'll have an array with 5 cards.

Declare what full houses, flushes, etc would require.
Use an if statement (If you don't mind lots of code) to compare the entered Array against possible hands.

I didn't necessarily give you any specific C++ code. However, if you Google C++ user input, you should find plenty of commands that may help you.

Good Luck

(And not sure about Linear search to be honest, you can use a Linear search, but if you did it the way I explained, you just have to compare hand to a series of conditionals.)


Sep 23, 2009 | Compilers & Programming Tools

1 Answer

A c program to implement transportation problem


#include<stdio.h>
#include<conio.h>

main()
{
int flag=0,flag1=0;
int s[10],d[10],sn,eop=1,dm,a[10][10];
int i,j,sum=0,min,x[10][10],k,fa,fb;

clrscr();
/* Getting The Input For the Problem*/

printf("Enter the number of Supply
");
scanf("%d",&sn);
printf("Enter the number of Demand
");
scanf("%d",&dm);
printf("Enter the Supply Values
");
for(i=0;i<sn;i++)
scanf("%d",&s[i]);
printf("Enter the Demand Values
");
for(j=0;j<sn;j++)
scanf("%d",&d[j]);
printf("Enter the elements of the array
");
for(i=0;i<sn;i++)
{
for(j=0;j<dm;j++)
{
scanf("%d",&a[i][j]);
}
}
/* Calculation For the Transportation */
i=0;j=0;
for(i=0,j=0;i<sn,j<dm;)
{
if(s[i]<d[j]) // Check supply less than demand
{
x[i][j]=a[i][j]*s[i]; // Calculate amount * supply
d[j]=d[j]-s[i]; // Calculate demand - supply
i++; // Increment i for the deletion of the row
or
column
}
else if(s[i]>=d[j]) //Check the supply greater than equal to
demand
{
x[i][j]=a[i][j]*d[j]; // Calculate amount * demand
s[i]=s[i]-d[j]; // Calculate supply - demand
j++; // Increment j for the deletion of the row
or
column
}

}
/* The Cost Matrix is Estimated here */
printf("Given Cost Matrix is :
");
for(fa=0;fa<sn;fa++)
{
for(fb=0;fb<dm;fb++)
{
printf("%d ",a[fa][fb]);
}
printf("
");
}
/* The Allocated Cost Matrix is */

printf("Allocated Cost Matrix is
");
for(fa=0;fa<sn;fa++)
{
for(fb=0;fb<dm;fb++)
{
printf("%d ",x[fa][fb]);
sum=sum+x[fa][fb];
}
printf("
");
}
/* Transportation Cost Estimated and Sum is Printed*/
printf("The Transportation cost:%d
",sum);
getch();
}

Apr 08, 2009 | Compilers & Programming Tools

1 Answer

Flexgrid with textbox


The arrow key will place you into the cell of your choice. In code you can determine the cell you are in by using the "Col" and "Row" properties. Here's a snippet for you:

Private Sub MSFlexGrid1_RowColChange()
Dim intCol As Integer
Dim intRow As Integer

intCol = MSFlexGrid1.Col
intRow = MSFlexGrid1.Row

Text1.Text = CStr(intCol) & " ; " & CStr(intRow)

End Sub

Mar 29, 2009 | Microsoft Visual Basic 6.0 for PC

1 Answer

I need a code(project) for vb for the game tictacto?


I suggest you this website:
http://www.codeproject.com/
This website is all about .NET programming, and you'll get all your answers there easily.
Enjoy it!

Feb 12, 2009 | Microsoft Visual Basic 6.0 for PC

1 Answer

Asp.Net


about the dynamic forms/pages, u can use sessions in asp.net C#, theyre very easy to use and try using commands like server.transfer and respond.redirect in ur code. for the connectivity thigee u asked, :) m sorry my friend u cant get it like a pan cake, u gotta study w3schools odbc connectivity in asp.net tag for this :P

Dec 21, 2008 | Microsoft ASP NET WEB MATRIX (583797)

2 Answers

Visual basic 6.0


Use a compare (instr) command to search the sentence for punctution and spaces. Increment a variable for each word found, resetting the search string and retaining the start position of each find.

Feb 27, 2008 | Compilers & Programming Tools

1 Answer

Program


I wrote this as a vbscript. It's Visual Basic code in windows script. If you have XP, just copy the text into notepad and save it as "vowel.vbs". Now double click the newly created script file.

' vowel.vbs
'
' This VBScript is used to count the vowels and consonants in a string.
' Designed and Tested on Windows XP Pro SP2
'
' Version 1.0.0 - 02.20.2008
'
' This code may be freely distributed or modified.
' -----------------------------------------------------------------'

Option Explicit
Dim str
Dim vowels
Dim consonants
Dim i

vowels = 0
consonants = 0
str = "hello"

for i = 1 to len(str)
select case mid(str,i,1)
case "a"
vowels = vowels + 1
case "e"
vowels = vowels + 1
case "i"
vowels = vowels + 1
case "o"
vowels = vowels + 1
case "u"
vowels = vowels + 1
case else
consonants = consonants + 1
end select
next

msgbox "Vowels = " & vowels
msgbox "Consonants = " & consonants
'End of script.

Feb 21, 2008 | Compilers & Programming Tools

2 Answers

Visual basic code


'Text1 is a textbox or a string you can use

Private Sub Command1_Click()
Dim a
Dim vow, con As Integer
vow = 0
con = 0
For i = 1 To Len(Text1)
a = Mid(Text1, i, 1)
If (a = "a" Or a = "e" Or a = "i" Or a = "o" Or a = "u") Then
vow = vow + 1
Else
con = con + 1
End If
Next
MsgBox "Vowels: " & vow & vbNewLine & "Consonants : " & con

End Sub

Feb 19, 2008 | Compilers & Programming Tools

Not finding what you are looking for?
Compilers & Programming Tools Logo

Related Topics:

394 people viewed this question

Ask a Question

Usually answered in minutes!

Top Intel Compilers & Programming Tools Experts

Michael Thomas
Michael Thomas

Level 3 Expert

3051 Answers

Robin Hill
Robin Hill

Level 3 Expert

1251 Answers

kakima

Level 3 Expert

96738 Answers

Are you an Intel Compiler and Programming Tool Expert? Answer questions, earn points and help others

Answer questions

Manuals & User Guides

Loading...