#include <iostream.h>
#include<conio.h>
#include <string>
using namespace std;
void sortMyArray(int arr[], int size);
void swapMyNumbers(int& x, int& y);
int main(){
//first array
int A[3][3],B[3][3],counter = 0,result[18];
string container = "";
char holder;
// first matrix input
cout << "Please enter the Elements of First Matrix:";
cin >> container;
for (int i = 0; i < 3 ; i++){
for (int j = 0; j < 3 ; j++){
holder = container[counter];
A[i][j] = atoi( &holder );
counter++;
}
}
//end of first part
container = "";
counter = 0;
cout << "Please enter the Elements of Second Matrix:";
cin >> container;
for (int i = 0; i < 3 ; i++){
for (int j = 0; j < 3 ; j++){
holder = container[counter];
B[i][j] = atoi( &holder );
counter++;
}
}
//end of second part
//storing first 2dimensioal array into single dimensional array
counter = 0;
for (int i = 0; i < 3 ; i++){
for (int j = 0; j < 3 ; j++){
result[counter] = A[i][j];
counter++;
}
}
//appending second 2dimensioal array into single dimensional array
counter = 9;
for (int i = 0; i < 3 ; i++){
for (int j = 0; j < 3 ; j++){
result[counter] = B[i][j];
counter++;
}
}
//sorting in DESC order i used bubble sort tech here
//out put
sortMyArray(result, 18);
for (int z = 0; z < 18 ; z++){
cout << " " <<result[z];
}
cout << "\n";
system("pause");
return 0;
}
void sortMyArray(int arr[], int size)
{
int last = size - 2;
int isChanged = 1;
while (last >= 0 && isChanged)
{
isChanged = 0;
for (int k = 0; k <= last; k++)
if (arr[k] < arr[k+1])
{
swapMyNumbers(arr[k], arr[k+1]);
isChanged = 1;
}
last--;
}
}
void swapMyNumbers(int& x, int& y)
{
int temp;
temp = x;
x = y;
y = temp;
}
see attachment for right one dude
--
Regards
Imran bashir
--
We say, "Be one as Pakistani Nation and grow up for Pakistan's Future". Wish you all the best. Join www.vuaskari.com,
To post to this group, send email to vuaskari_com@googlegroups.com
Visit these groups:
This (Main) Group:http://groups.google.com/group/vuaskari_com?hl=en?hl=en
MIT/MCS Group: http://groups.google.com/group/vu_askarimit?hl=en?hl=en
HRM Group: http://groups.google.com/group/askari_hrm?hl=en?hl=en
Banking Group: http://groups.google.com/group/askari_banking?hl=en?hl=en
Management: https://groups.google.com/group/vuaskari_mgt?hl=en
Marketing: https://groups.google.com/group/vuaskari_mkt?hl=en
MIS Group: http://groups.google.com/group/askari_mis?hl=en
#include<conio.h>
#include <string>
using namespace std;
void sortMyArray(int arr[], int size);
void swapMyNumbers(int& x, int& y);
int main(){
//first array
int A[3][3],B[3][3],counter = 0,result[18];
string container = "";
char holder;
// first matrix input
cout << "Please enter the Elements of First Matrix:";
cin >> container;
for (int i = 0; i < 3 ; i++){
for (int j = 0; j < 3 ; j++){
holder = container[counter];
A[i][j] = atoi( &holder );
counter++;
}
}
//end of first part
container = "";
counter = 0;
cout << "Please enter the Elements of Second Matrix:";
cin >> container;
for (int i = 0; i < 3 ; i++){
for (int j = 0; j < 3 ; j++){
holder = container[counter];
B[i][j] = atoi( &holder );
counter++;
}
}
//end of second part
//storing first 2dimensioal array into single dimensional array
counter = 0;
for (int i = 0; i < 3 ; i++){
for (int j = 0; j < 3 ; j++){
result[counter] = A[i][j];
counter++;
}
}
//appending second 2dimensioal array into single dimensional array
counter = 9;
for (int i = 0; i < 3 ; i++){
for (int j = 0; j < 3 ; j++){
result[counter] = B[i][j];
counter++;
}
}
//sorting in DESC order i used bubble sort tech here
//out put
sortMyArray(result, 18);
for (int z = 0; z < 18 ; z++){
cout << " " <<result[z];
}
cout << "\n";
system("pause");
return 0;
}
void sortMyArray(int arr[], int size)
{
int last = size - 2;
int isChanged = 1;
while (last >= 0 && isChanged)
{
isChanged = 0;
for (int k = 0; k <= last; k++)
if (arr[k] < arr[k+1])
{
swapMyNumbers(arr[k], arr[k+1]);
isChanged = 1;
}
last--;
}
}
void swapMyNumbers(int& x, int& y)
{
int temp;
temp = x;
x = y;
y = temp;
}
see attachment for right one dude
On Mon, May 2, 2011 at 4:04 PM, mc100405406 Mobeen Mohsin <mc100405406@vu.edu.pk> wrote:
Imran u r right the solution is wrongOn Mon, May 2, 2011 at 3:17 PM, (`*•.¸Imran Mughal¸.•*´ ) <vuimran1@gmail.com> wrote:
your solution is wrong. miss madiha. see attachment for right oneOn Mon, May 2, 2011 at 1:30 PM, Madiha Malik <mc110203633@vu.edu.pk> wrote:
here is cs201#include<iostream.h>
#include<conio.h>
main()cout<<"Please enter the Elements of 1st Matrix: ";
{
int arry1[3][3],arry2[3][3],arry[18],index,temp,max;
for(int e=0;e<3;e++)
{
for(int m=0;m<3;m++)
{
cin>>arry1[e][m];
}
}
cout<<"Please enter the Elements of 2nd Matrix: ";
for(int e=0;e<3;e++)
{
for(int m=0;m<3;m++)
{
cin>>arry2[e][m];
}
}
index=0;
for(int e=0;e<3;e++)
{
for(int m=0;m<3;m++)
{
arry[index]=arry1[e][m];
index++;
}
}
index=9;
for(int e=0;e<3;e++)
{
for(int m=0;m<3;m++)
{
arry[index]=arry2[e][m];
index++;
}
}
for(int e=0;e<18;e++)
{
for(int m=e;m<18;m++)
{
if(arry[e]<arry[m])
{
temp=arry[e];
arry[e]=arry[m];
arry[m]=temp;
}
}}
cout<<"Sorted Values from Both the Matrices are: "<<endl;
for(int e=0;e<18;e++)
{
cout<<arry[e]<<" ";
}
getch();
}On Mon, May 2, 2011 at 1:00 AM, mc110201340 Asaf Faiz <mc110201340@vu.edu.pk> wrote:
plzzzzzz send me solution of cs201 2nd assignment ,,,,plzzzzzzzzzz send i will submit it after making a lot of changes so plzzzzzzzzzzzzzzzzzzzzzzzzz send nowOn Fri, Apr 29, 2011 at 10:24 PM, mc110201752 Ayesha Quddoos <mc110201752@vu.edu.pk> wrote:
kb tak upload kerni hai assignment 2nd for cs201..plz guide me:( matrix aata hai bt in c how will make programme plz plzzzzz guide me
On Fri, Apr 29, 2011 at 9:06 PM, mc100400213 Sharjeel Anjum <mc100400213@vu.edu.pk> wrote:Abi nai bani cs201, or cs 601 ki......wait guys for 24 hours
--
We say, "Be one as Pakistani Nation and grow up for Pakistan's Future". Wish you all the best. Join www.vuaskari.com,
To post to this group, send email to vuaskari_com@googlegroups.com
Visit these groups:
This (Main) Group:http://groups.google.com/group/vuaskari_com?hl=en?hl=en
MIT/MCS Group: http://groups.google.com/group/vu_askarimit?hl=en?hl=en
HRM Group: http://groups.google.com/group/askari_hrm?hl=en?hl=en
Banking Group: http://groups.google.com/group/askari_banking?hl=en?hl=en
Management: https://groups.google.com/group/vuaskari_mgt?hl=en
Marketing: https://groups.google.com/group/vuaskari_mkt?hl=en
MIS Group: http://groups.google.com/group/askari_mis?hl=en
--
We say, "Be one as Pakistani Nation and grow up for Pakistan's Future". Wish you all the best. Join www.vuaskari.com,
To post to this group, send email to vuaskari_com@googlegroups.com
Visit these groups:
This (Main) Group:http://groups.google.com/group/vuaskari_com?hl=en?hl=en
MIT/MCS Group: http://groups.google.com/group/vu_askarimit?hl=en?hl=en
HRM Group: http://groups.google.com/group/askari_hrm?hl=en?hl=en
Banking Group: http://groups.google.com/group/askari_banking?hl=en?hl=en
Management: https://groups.google.com/group/vuaskari_mgt?hl=en
Marketing: https://groups.google.com/group/vuaskari_mkt?hl=en
MIS Group: http://groups.google.com/group/askari_mis?hl=en
--
We say, "Be one as Pakistani Nation and grow up for Pakistan's Future". Wish you all the best. Join www.vuaskari.com,
To post to this group, send email to vuaskari_com@googlegroups.com
Visit these groups:
This (Main) Group:http://groups.google.com/group/vuaskari_com?hl=en?hl=en
MIT/MCS Group: http://groups.google.com/group/vu_askarimit?hl=en?hl=en
HRM Group: http://groups.google.com/group/askari_hrm?hl=en?hl=en
Banking Group: http://groups.google.com/group/askari_banking?hl=en?hl=en
Management: https://groups.google.com/group/vuaskari_mgt?hl=en
Marketing: https://groups.google.com/group/vuaskari_mkt?hl=en
MIS Group: http://groups.google.com/group/askari_mis?hl=en--
Man said to ALLAH"i hate life"
ALLAH replied "who asked u to love life just love me the life will be beautiful"
MCS First Semister
Skype : MADIHA (from kamra)
--We say, "Be one as Pakistani Nation and grow up for Pakistan's Future". Wish you all the best. Join www.vuaskari.com,
To post to this group, send email to vuaskari_com@googlegroups.com
Visit these groups:
This (Main) Group:http://groups.google.com/group/vuaskari_com?hl=en?hl=en
MIT/MCS Group: http://groups.google.com/group/vu_askarimit?hl=en?hl=en
HRM Group: http://groups.google.com/group/askari_hrm?hl=en?hl=en
Banking Group: http://groups.google.com/group/askari_banking?hl=en?hl=en
Management: https://groups.google.com/group/vuaskari_mgt?hl=en
Marketing: https://groups.google.com/group/vuaskari_mkt?hl=en
MIS Group: http://groups.google.com/group/askari_mis?hl=en
--
Regards
Imran bashir
--
We say, "Be one as Pakistani Nation and grow up for Pakistan's Future". Wish you all the best. Join www.vuaskari.com,
To post to this group, send email to vuaskari_com@googlegroups.com
Visit these groups:
This (Main) Group:http://groups.google.com/group/vuaskari_com?hl=en?hl=en
MIT/MCS Group: http://groups.google.com/group/vu_askarimit?hl=en?hl=en
HRM Group: http://groups.google.com/group/askari_hrm?hl=en?hl=en
Banking Group: http://groups.google.com/group/askari_banking?hl=en?hl=en
Management: https://groups.google.com/group/vuaskari_mgt?hl=en
Marketing: https://groups.google.com/group/vuaskari_mkt?hl=en
MIS Group: http://groups.google.com/group/askari_mis?hl=en
--
We say, "Be one as Pakistani Nation and grow up for Pakistan's Future". Wish you all the best. Join www.vuaskari.com,
To post to this group, send email to vuaskari_com@googlegroups.com
Visit these groups:
This (Main) Group:http://groups.google.com/group/vuaskari_com?hl=en?hl=en
MIT/MCS Group: http://groups.google.com/group/vu_askarimit?hl=en?hl=en
HRM Group: http://groups.google.com/group/askari_hrm?hl=en?hl=en
Banking Group: http://groups.google.com/group/askari_banking?hl=en?hl=en
Management: https://groups.google.com/group/vuaskari_mgt?hl=en
Marketing: https://groups.google.com/group/vuaskari_mkt?hl=en
MIS Group: http://groups.google.com/group/askari_mis?hl=en
--
Regards
Imran bashir
--
We say, "Be one as Pakistani Nation and grow up for Pakistan's Future". Wish you all the best. Join www.vuaskari.com,
To post to this group, send email to vuaskari_com@googlegroups.com
Visit these groups:
This (Main) Group:http://groups.google.com/group/vuaskari_com?hl=en?hl=en
MIT/MCS Group: http://groups.google.com/group/vu_askarimit?hl=en?hl=en
HRM Group: http://groups.google.com/group/askari_hrm?hl=en?hl=en
Banking Group: http://groups.google.com/group/askari_banking?hl=en?hl=en
Management: https://groups.google.com/group/vuaskari_mgt?hl=en
Marketing: https://groups.google.com/group/vuaskari_mkt?hl=en
MIS Group: http://groups.google.com/group/askari_mis?hl=en
Comments
Post a Comment