hi
i'm very new to the programming. i have two questions related to matrices. Hope somoeone will help me with the code or even pseudo code is fine.
1. A c# function that returns TRUE when a matrix have same elements in anyone of the rows.
eg. 1 2 4
1 1 1
2 2 4
The function for the above matrix should return True otherwise false.
2. A c# function which takes two input values and displays a matrix in the following pattern
input: a,b
a a a a
a a a b
a a b b
a b b b
b b b b
I would appreciate your help
matrix programs in C#
Started by solarexplode, Mar 19 2009 09:29 PM
2 replies to this topic
#1
Posted 19 March 2009 - 09:29 PM
|
|
|
#2
Posted 20 March 2009 - 08:15 AM
Given that the matrix will be stored in an array, what do you have so far?
#3
Posted 23 November 2009 - 03:41 AM
solarexplode said:
hi
i'm very new to the programming. i have two questions related to matrices. Hope somoeone will help me with the code or even pseudo code is fine.
1. A c# function that returns TRUE when a matrix have same elements in anyone of the rows.
eg. 1 2 4
1 1 1
2 2 4
The function for the above matrix should return True otherwise false.
2. A c# function which takes two input values and displays a matrix in the following pattern
input: a,b
a a a a
a a a b
a a b b
a b b b
b b b b
I would appreciate your help
i'm very new to the programming. i have two questions related to matrices. Hope somoeone will help me with the code or even pseudo code is fine.
1. A c# function that returns TRUE when a matrix have same elements in anyone of the rows.
eg. 1 2 4
1 1 1
2 2 4
The function for the above matrix should return True otherwise false.
2. A c# function which takes two input values and displays a matrix in the following pattern
input: a,b
a a a a
a a a b
a a b b
a b b b
b b b b
I would appreciate your help
public static bool meth(int[,]arr)
{
for(int i=0;i<=arr.GetUpperBound(0);i++)
{
List<int> ll=new List<int>();
for(int j=0;j<=arr.GetUpperBound(1);j++)
{
ll.Add(arr[i,j]);
}
ll.Sort();
if(ll[0]==ll[ll.Count-1])return true;
}
return false;
}// you have to add using System.Collections.Generic; as header for list to work
2nd problem:-
public static void meth(char a,char b)
{
for(int i=0;i<5;i++)
{
for(int j=0;j<5-i-1;j++)
{
Console.Write(a+" ");
}
for(int j=5-i;j<5;j++)
{
Console.Write(b+" ");
}Console.WriteLine();
}
}
Edited by Jaan, 23 November 2009 - 07:41 AM.
Please use code tags when you are posting your codes!


Sign In
Create Account

Back to top









