| | |
Easy program
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Aug 2005
Posts: 49
Reputation:
Solved Threads: 1
C++ program that input rectangular matrix A nxm (integer) and finds out the indexes of most occurred element and counts how many times he occurs.
I just can't do it
I just can't do it
•
•
Join Date: Aug 2005
Posts: 49
Reputation:
Solved Threads: 1
But I gotta do it till tommorow! I don't have time!!!
Last edited by ohyeah; Aug 21st, 2008 at 7:52 am.
>>I don't have time!!!
Such is the life of a programmer -- we all feel that way frequently, especially when we don't start coding until just before the program is due to be shipped. That's when you load up on peanutbutter & jelly sandwitches, then go for a 24-hour day at your computer.
Write your program in very small steps. What's the first thing you have to do? write the main() function and create an array! write that and get it to compile cleanly before going on to the next step.
Do in small steps and you will soon have your program written.
Post back here with the code you have written and with more specific questions. Crying will not help.
Such is the life of a programmer -- we all feel that way frequently, especially when we don't start coding until just before the program is due to be shipped. That's when you load up on peanutbutter & jelly sandwitches, then go for a 24-hour day at your computer.
Write your program in very small steps. What's the first thing you have to do? write the main() function and create an array! write that and get it to compile cleanly before going on to the next step.
Do in small steps and you will soon have your program written.
Post back here with the code you have written and with more specific questions. Crying will not help.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
•
•
Join Date: Aug 2005
Posts: 49
Reputation:
Solved Threads: 1
the post above really touch'd me!
C++ Syntax (Toggle Plain Text)
#include <iostream.h> int count,a[2][2]={0,2,2,3}; //primary matrix void main() { for(int i=0;i<5;i++) for(int j=0;j<5;j++) if(a[i][j]==a[i++][j++]) count++; cout<<a[i][j]<<count; }
Last edited by Ancient Dragon; Aug 21st, 2008 at 8:53 am. Reason: add code tags
your coding style needs a lot of improvement.
1) add { and } for clarity and to tell the compiler what lines go inside the loop. The way I placed it below is how your compiler would have treated it, which is probably not what you intended.
2) iostream.h is obsolete. Current c++ standard header files do not have extensions. But if you are using an ancient compiler such as Turbo C then you don't have any other choice but the use those obsolete header files. If you can you should get a current, free compiler.
1) add { and } for clarity and to tell the compiler what lines go inside the loop. The way I placed it below is how your compiler would have treated it, which is probably not what you intended.
2) iostream.h is obsolete. Current c++ standard header files do not have extensions. But if you are using an ancient compiler such as Turbo C then you don't have any other choice but the use those obsolete header files. If you can you should get a current, free compiler.
#include <iostream>
using namespace std;
int count,a[2][2]={0,2,2,3}; //primary matrix
int main() {
for(int i=0;i<5;i++)
{
for(int j=0;j<5;j++)
{
if(a[i][j]==a[i++][j++])
count++;
}
}
cout<<a[i][j]<<count;
} Last edited by Ancient Dragon; Aug 21st, 2008 at 9:03 am.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
And of course, int main returns an exit code. For good coding practice. 

#include <iostream>
using namespace std;
int count,a[2][2]={0,2,2,3}; //primary matrix
int main() {
for(int i=0;i<5;i++)
{
for(int j=0;j<5;j++)
{
if(a[i][j]==a[i++][j++])
count++;
}
}
cout<<a[i][j]<<count;
return 0;
} Last edited by murderotica; Aug 21st, 2008 at 11:57 pm.
An Avalanche In D Minor
![]() |
Similar Threads
- Help With Program (C++)
- Running Java Program outside an IDE (Java)
- simple program help (C++)
- program error for cd burner program (Windows NT / 2000 / XP)
- IP tracking? (Windows NT / 2000 / XP)
- Emergency.....easy Program Week Days (Java)
- Do variable names affect a program? (C)
- question (C++)
Other Threads in the C++ Forum
- Previous Thread: replacing windows functions with ubuntu linux
- Next Thread: Help Me Please
| Thread Tools | Search this Thread |
Tag cloud for C++
api application array arrays based beginner binary bmp c++ c/c++ calculator char char* class classes code compile compiler console conversion convert count data delete deploy dll download dynamic dynamiccharacterarray encryption error file format forms fstream function functions game givemetehcodez graph gui homeworkhelp iamthwee ifstream input int java lib library linkedlist linker list loop looping loops map math matrix memory microsoft newbie news number numbertoword output pointer problem program programming project python random read recursion recursive reference rpg simple sorting string strings temperature template templates test text text-file tree url variable vector video visual visualstudio void win32 windows winsock wordfrequency wxwidgets






