Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include "Header.h"
- #include <string>
- #include <vector>
- using namespace std;
- bool isTriPos(int A, int B, int C) {
- bool returnObject = false;
- if ((A + B) > C && (A + C) > B && (C + B) > A) {
- returnObject = true;
- }
- else {
- returnObject = false;
- }
- return returnObject;
- }
- class triangle {
- public:
- int A, B, C;
- int isTri;
- triangle(int inputA, int inputB, int inputC) {
- this->A = inputA;
- this->B = inputB;
- this->C = inputC;
- if (isTriPos(inputA, inputB, inputC)) {
- this->isTri = 1;
- }
- else {
- this->isTri = 0;
- }
- }
- };
- int counter = 0;
- void main() {
- if (isTriPos(5, 10, 25)) {
- cout << "yes" << endl;
- }
- vector <string> userInput = getInputFile("C:\\temp\\Tri.txt");
- vector <triangle> triList;
- vector <int> numbersData;
- for (int i = 0; i < userInput.size(); i++) {
- vector <string> userInputSplit = cstringsplit(userInput.at(i), " ");
- for (int b = 0; b < userInputSplit.size(); b++) {
- int tempInt = String2Int(userInputSplit.at(b));
- if (tempInt > 0) {
- numbersData.push_back(tempInt);
- }
- }
- }
- for (int i = 0; i < numbersData.size(); i = i + 3) {
- triangle temp(numbersData.at(i), numbersData.at(i + 1), numbersData.at(i + 2));
- triList.push_back(temp);
- }
- for (int i = 0; i < triList.size(); i++) {
- triangle triPtr = triList.at(i);
- if(triPtr.isTri == 1){
- counter++;
- }
- }
- cout << counter << endl;
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment