Skip to content

Commit 5def81d

Browse files
committed
Done 2 exercises of Catalyst Coding Contest
1 parent 2012b4e commit 5def81d

30 files changed

+605
-0
lines changed

CCC18-11/.buildings.cpp.swp

12 KB
Binary file not shown.

CCC18-11/1/0.out

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
5 8 9 10

CCC18-11/1/1.out

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
13 71 73 85 93 96 127 149 169 211 218 247 276 292 294 295 360 382

CCC18-11/1/2.out

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
5 15 35 59 86 119 174 421 452

CCC18-11/1/3.out

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0

CCC18-11/1/Level1.pdf

3.04 MB
Binary file not shown.

CCC18-11/1/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
all:
2+
g++ -std=c++11 buildings.cpp -Wall -o exeBuildings

CCC18-11/1/buildings.cpp

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#include <iostream>
2+
#include <algorithm>
3+
#include <vector>
4+
5+
bool isContained(std::vector<unsigned int> list, unsigned int height){
6+
unsigned int i;
7+
8+
for(i = 0; i < list.size(); i++){
9+
if(list.at(i) == height)
10+
return true;
11+
}
12+
return false;
13+
}
14+
15+
void printHeights(
16+
std::vector<std::vector<unsigned int> > city)
17+
{
18+
unsigned int i, j;
19+
std::vector<unsigned int> list;
20+
21+
for(i = 0; i < city.size(); i++){
22+
for(j = 0; j < city.at(i).size(); j++){
23+
if(city.at(i).at(j) != 0 &&
24+
!isContained(list, city.at(i).at(j)))
25+
list.push_back(city.at(i).at(j));
26+
}
27+
}
28+
29+
std::sort(list.begin(), list.end());
30+
31+
if(list.size() != 0){
32+
for(i = 0; i < list.size(); i++){
33+
std::cout << list.at(i);
34+
if(i != list.size() -1)
35+
std::cout << " ";
36+
else
37+
std::cout << "\n";
38+
}
39+
}else
40+
std::cout << "0\n";
41+
}
42+
43+
int main(void)
44+
{
45+
unsigned int rows, columns, temp, i, j;
46+
std::cin >> rows;
47+
std::cin >> columns;
48+
std::vector<std::vector<unsigned int> > city(rows);
49+
50+
for(i = 0; i < rows; i++){
51+
52+
for(j = 0; j < columns; j++){
53+
std::cin >> temp;
54+
city.at(i).push_back(temp);
55+
}
56+
}
57+
58+
printHeights(city);
59+
60+
return 0;
61+
}

CCC18-11/1/ejemplo.in

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
4 4
2+
0 0 0 1
3+
0 0 0 0
4+
0 0 0 0
5+
2 0 0 0

CCC18-11/1/exeBuildings

50.3 KB
Binary file not shown.

0 commit comments

Comments
 (0)