wheelsmanx

AOC DAY 3 PART 1 Source.cpp

May 15th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. #include <iostream>
  2. #include "Header.h"
  3. #include <string>
  4. #include <vector>
  5.  
  6. using namespace std;
  7.  
  8. bool isTriPos(int A, int B, int C) {
  9. bool returnObject = false;
  10. if ((A + B) > C && (A + C) > B && (C + B) > A) {
  11. returnObject = true;
  12. }
  13. else {
  14. returnObject = false;
  15. }
  16. return returnObject;
  17. }
  18.  
  19. class triangle {
  20. public:
  21. int A, B, C;
  22. int isTri;
  23. triangle(int inputA, int inputB, int inputC) {
  24. this->A = inputA;
  25. this->B = inputB;
  26. this->C = inputC;
  27. if (isTriPos(inputA, inputB, inputC)) {
  28. this->isTri = 1;
  29. }
  30. else {
  31. this->isTri = 0;
  32. }
  33. }
  34. };
  35.  
  36. int counter = 0;
  37.  
  38. void main() {
  39. if (isTriPos(5, 10, 25)) {
  40. cout << "yes" << endl;
  41. }
  42. vector <string> userInput = getInputFile("C:\\temp\\Tri.txt");
  43. vector <triangle> triList;
  44. vector <int> numbersData;
  45. for (int i = 0; i < userInput.size(); i++) {
  46. vector <string> userInputSplit = cstringsplit(userInput.at(i), " ");
  47. for (int b = 0; b < userInputSplit.size(); b++) {
  48. int tempInt = String2Int(userInputSplit.at(b));
  49. if (tempInt > 0) {
  50. numbersData.push_back(tempInt);
  51. }
  52. }
  53. }
  54. for (int i = 0; i < numbersData.size(); i = i + 3) {
  55. triangle temp(numbersData.at(i), numbersData.at(i + 1), numbersData.at(i + 2));
  56. triList.push_back(temp);
  57. }
  58. for (int i = 0; i < triList.size(); i++) {
  59. triangle triPtr = triList.at(i);
  60. if(triPtr.isTri == 1){
  61. counter++;
  62. }
  63. }
  64. cout << counter << endl;
  65. system("pause");
  66. }
Advertisement
Add Comment
Please, Sign In to add comment