15,911,786 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Sohkar A Lensky (Top 10 by date)
Sohkar A Lensky
12-Oct-22 11:33am
View
Yeah it makes sense, since im kindda new to c++ i wasnt aware of these. Thank you very much for working on this
Sohkar A Lensky
12-Oct-22 8:27am
View
Of course i would like to see your solution, mine is actually sent back but id like your take on it :3
Sohkar A Lensky
10-Oct-22 1:01am
View
I do not know , it was sent to me for learning purposes, they told me its easy , will not take too long xD
Sohkar A Lensky
10-Oct-22 1:00am
View
It is fixed at [0][0] but your matrix is essentially n-1 because the cities can send to themselves with 0 amount of time (if i understood right)
Sohkar A Lensky
9-Oct-22 2:24am
View
True , i did that but unfortunately i passed out for a couple of days, tho i had a revelation:
They can go anywhere , anytime , so i take every smallest number, i can ignore the first then add them together so in the end : 5+20+10 = 35
Sohkar A Lensky
7-Oct-22 10:44am
View
is it okay like this ? sorry first time user on this website
Sohkar A Lensky
7-Oct-22 10:28am
View
Deleted
there i posted it as a solution, the commenting was so messy
Sohkar A Lensky
7-Oct-22 10:27am
View
Deleted
alright my bad again, here is my code :
#include <iostream>
using namespace std;
class Matrix
{
public:
int GetRows()
{
return rows;
}
int GetColumns()
{
return columns;
}
void SetMatrixSize(int size)
{
rows = size;
columns = size;
}
void SetNumberOfRows(int rowAmount)
{
rows = rowAmount;
}
void SetNumberOfColumns(int columnAmount)
{
columns = columnAmount;
}
void NextRow(int x)
{
x + 1;
}
private:
unsigned int rows;
unsigned int columns;
};
int main()
{
Matrix obj;
int amountOfCity;
std::cout << "Enter the amount of city : " << endl;
cin >> amountOfCity;
//Clamping Number Of City
if (amountOfCity < 1)
{
amountOfCity = 1;
std::cout<< "Cannot have less than one city !"<<endl;
}
="" if="" (amountofcity=""> 100)
{
amountOfCity = 100;
std::cout<< "Cannot have more than 100 cities ! " << endl;
}
obj.SetMatrixSize(amountOfCity -1);
//Allocating memory
int** matrix = new int* [obj.GetRows()];
for (unsigned int i = 0; i < obj.GetRows(); i++)
{
matrix[i] = new int[obj.GetColumns()];
}
int iteration = 0;
//Set Value for element in the matrix with user input
for (int x = 0; x < obj.GetRows(); x++)
{
for (int y = 0; y < obj.GetColumns(); y++)
{
//Initialize to 0
matrix[x][y] = 0;
int value = 0;
if (y <= iteration)
{
std::cout << "Enter the values : " << endl;
cin >> value;
matrix[x][y] = value;
}
if (y == obj.GetColumns() -1)
{
iteration++;
}
}
}
//Displaying the matrix
std::cout << "Here is your matrix : " << endl;
for (int x = 0; x < obj.GetRows(); x++)
{
for (int y = 0; y < obj.GetColumns(); y++)
{
std::cout <<" "<
Sohkar A Lensky
7-Oct-22 10:16am
View
i thought showing the whole thing would help people understand what was happening x)
Sohkar A Lensky
7-Oct-22 10:15am
View
well my bad ive never written on code forums and stuff , at the moment i have pretty much everything , the 2d array , triangular matrix etc like i wrote i am only stuck at the end , the calculation to get the requested output : 35 based on my matrix just this little part , not the whole challenge of course, so yeah thats my next step , i tried adding everything then dividing , didnt work , i tried getting all of the smallest numbers together , couldnt filter through the array. so yeah thats where i am mainly
Show More