int main() {
   const int ARRAY_SIZE = 10;
   int intArray[ARRAY_SIZE] = {4, 5, 9, 12, -4, 0, -57, 30987, -287, 1};
   int targetValue = 12;
   int targetPos = 0;
   while (intArray[targetPos] != targetValue && targetPos < ARRAY_SIZE)
      targetPos++;
   return 0;
}

---

int main() {
   const int ARRAY_SIZE = 10;
   int intArray[ARRAY_SIZE] = {4, 5, 9, 12, -4, 0, -57, 30987, -287, 1};
   int largestValue = intArray[0];
   for (int i = 1; i < ARRAY_SIZE; i++) {
      if (intArray[i] > largestValue) largestValue = intArray[i];
   }	
   return 0;
}

---

#include <stdlib.h>

int compareFunc(const void * voidA, const void * voidB) {
   int * intA = (int *)(voidA);
   int * intB = (int *)(voidB);
   return *intA - *intB;
}

int main() {
   const int ARRAY_SIZE = 10;
   int intArray[ARRAY_SIZE] = {87, 28, 100, 78, 84, 98, 75, 70, 81, 68};
   qsort(intArray, ARRAY_SIZE, sizeof(int), compareFunc);
   return 0;
}

---

int main() {
   const int ARRAY_SIZE = 10;
   int intArray[ARRAY_SIZE] = {87, 28, 100, 78, 84, 98, 75, 70, 81, 68};
   int start = 0;
   int end = ARRAY_SIZE - 1;
   for (int i = start + 1; i <= end; i++) {
      for (int j = i; j > start && intArray[j-1] > intArray[j]; j--) {
         int temp = intArray[j-1];
         intArray[j-1] = intArray[j];
         intArray[j] = temp;
      }
   }	
   return 0;
}

---


int main() {
   const int ARRAY_SIZE = 10;
   int gradeArray[ARRAY_SIZE] = {87, 76, 100, 97, 64, 83, 88, 92, 74, 95};
   double sum = 0;
   for (int i = 0; i < ARRAY_SIZE; i++) {
      sum += gradeArray[i];
   }
   double average = sum / ARRAY_SIZE;
   return 0;
}

---

int main() {
   const int ARRAY_SIZE = 10;
   double vendorPayments[ARRAY_SIZE] = {4, 5, 9, 12, -4, 0, -57, 30987, -287, 1};
   int countNegative = 0;
   for (int i = 0; i < ARRAY_SIZE; i++) {
      if (vendorPayments[i] < 0) countNegative++;
   }	
   return 0;
}

---


int main() {
   const int ARRAY_SIZE = 12;
   int surveyData[ARRAY_SIZE] = {4, 7, 7, 9, 9, 9, 8, 3, 3, 3, 3, 10};
   int mostFrequent;
   int highestFrequency = 0;
   int currentFrequency = 0;
   for (int i = 0; i < ARRAY_SIZE; i++) {
      currentFrequency++;
      if (i == ARRAY_SIZE - 1 || surveyData[i] != surveyData[i + 1]) {
         if (currentFrequency > highestFrequency) {
            highestFrequency = currentFrequency;
            mostFrequent = surveyData[i];
         }
         currentFrequency = 0;
      }
   }
   return 0;
}

---

#include <stdlib.h>

int compareFunc(const void * voidA, const void * voidB) {
   int * intA = (int *)(voidA);
   int * intB = (int *)(voidB);
   return *intA - *intB;
}

int main() {
   const int ARRAY_SIZE = 12;
   int surveyData[ARRAY_SIZE] = {4, 7, 3, 8, 9, 7, 3, 9, 9, 3, 3, 10};

   qsort(surveyData, ARRAY_SIZE, sizeof(int), compareFunc);
   int mostFrequent;
   int highestFrequency = 0;
   int currentFrequency = 0;
   for (int i = 0; i < ARRAY_SIZE; i++) {
      currentFrequency++;
      if (i == ARRAY_SIZE - 1 || surveyData[i] != surveyData[i + 1]) {
         if (currentFrequency > highestFrequency) {
            highestFrequency = currentFrequency;
            mostFrequent = surveyData[i];
         }
         currentFrequency = 0;
      }
   }
   return 0;
}

---

int main() {
   const int ARRAY_SIZE = 12;
   int surveyData[ARRAY_SIZE] = {4, 7, 3, 8, 9, 7, 3, 9, 9, 3, 3, 10};

   const int MAX_RESPONSE = 10;
   int histogram[MAX_RESPONSE];
   for (int i = 0; i < 10; i++) {
      histogram[i] = 0;
   }
   for (int i = 0; i < ARRAY_SIZE; i++) {
      histogram[surveyData[i] - 1]++;
   }
   int mostFrequent = 0;
   for (int i = 1; i < MAX_RESPONSE; i++) {
      if (histogram[i] > histogram[mostFrequent]) mostFrequent = i;
   }
   mostFrequent++;
   return 0;
}

---

#include <iostream>
using std::cout;
using std::cin;

int main() {
   double grossSales;
   double cost;
   int category;

   cout << "Sprzeda: "; 
   cin >> grossSales;

   const int NUM_CATEGORIES = 4;
   const double categoryThresholds[NUM_CATEGORIES] = {0.0, 150000.0, 450000.0, 1500000.0};
   const double licenseCost[NUM_CATEGORIES] = {75.0, 600.0,3000.0, 15000.0};
   category = 0;
   while (category < NUM_CATEGORIES && categoryThresholds[category] <= grossSales)
      category++;
   cost = licenseCost[category - 1];
   cout << cost << "\n";
   return 0;
}

---

#include <iostream>
using std::cout;
using std::cin;
using std::string;

struct student {
   int grade;
   int studentID;
   string name;
};

int main() {
   const int ARRAY_SIZE = 10;
   student studentArray[ARRAY_SIZE] = {
      {87, 10001, "Krzysztof"},
      {28, 10002, "Bernard"},
      {100, 10003, "Wojciech"},
      {78, 10004, "Robert"},
      {84, 10005, "Bogdan"},
      {98, 10006, "Boena"},
      {75, 10007, "Edyta"},
      {70, 10008, "Beata"},
      {81, 10009, "Alicja"},
      {68, 10010, "Joanna"}
	};

   int highest = studentArray[0].grade;
   for (int i = 1; i < ARRAY_SIZE; i++) {
      if (studentArray[i].grade > highest) highest = studentArray[i].grade;
   }

   int highPosition = 0;
   for (int i = 1; i < ARRAY_SIZE; i++) {
      if (studentArray[i].grade > studentArray[highPosition].grade) {
         highPosition = i;
      }
   }

   return 0;
}

---

int main() {
   const int NUM_AGENTS = 3;
   const int NUM_MONTHS = 12;
   int sales[NUM_AGENTS][NUM_MONTHS] = {
      {1856, 498, 30924, 87478, 328, 2653, 387, 3754, 387587, 2873, 276, 32},
      {5865, 5456, 3983, 6464, 9957, 4785, 3875, 3838, 4959, 1122, 7766, 2534},
      {23, 55, 67, 99, 265, 376, 232, 223, 4546, 564, 4544, 3434}	
   };

   int highestSales = sales[0][0];
   for(int agent = 0; agent < NUM_AGENTS; agent++) {
      for(int month = 0; month < NUM_MONTHS; month++) {
         if (agent != 0 || month != 0)
         if (sales[agent][month] > highestSales)
            highestSales = sales[agent][month];
      }
   }

   return 0;
}

---

#include <iostream>
using std::cout;
using std::cin;

int main() {
   int ARRAY_SIZE;
   cout << "Liczba odpowiedzi sondaowych: ";
   cin >> ARRAY_SIZE;
   int *surveyData = new int[ARRAY_SIZE];
   for(int i = 0; i < ARRAY_SIZE; i++) {
      out << "Odpowied sondaowa " << i + 1 << ": ";
      cin >> surveyData[i];
   }
   // ...gdy ju zakoczylimy dziaania...
   delete[] surveyData;

   return 0;
}

---

#include <iostream>
using std::cout;
using std::cin;
#include <vector>
using std::vector;

int main() {
   vector<int> surveyData;
   surveyData.reserve(30);
   int surveyResponse;
   cout << "Wprowad kolejn odpowied sondaow lub -1, by zakoczy: ";
   cin >> surveyResponse;
   while (surveyResponse != -1) {
      surveyData.push_back(surveyResponse);
      cout << "Wprowad kolejn odpowied sondaow lub -1, by zakoczy: ";
   cin >> surveyResponse;
   } 
   int vectorSize = surveyData.size();
   const int MAX_RESPONSE = 10;
   int histogram[MAX_RESPONSE];
   for (int i = 0; i < 10; i++) {
      histogram[i] = 0;
   }
   for (int i = 0; i < vectorSize; i++) {
      histogram[surveyData[i] - 1]++;
   }
   int mostFrequent = 0;
   for (int i = 1; i < MAX_RESPONSE; i++) {
      if (histogram[i] > histogram[mostFrequent]) mostFrequent = i;
   }
   mostFrequent++;

   return 0;
}

---

#include <iostream>
using std::cout;
using std::cin;

int main() {
   const int MAX_RESPONSE = 10;
   int histogram[MAX_RESPONSE];
   for (int i = 0; i < MAX_RESPONSE; i++) {
      histogram[i] = 0;
   }
   int surveyResponse;
   cout << "Wprowad kolejn odpowied sondaow lub -1, by zakoczy: ";
   cin >> surveyResponse;
   while (surveyResponse != -1) {
      histogram[surveyResponse - 1]++;
      cout << "Wprowad kolejn odpowied sondaow lub -1, by zakoczy: ";
      cin >> surveyResponse;
   } 
   int mostFrequent = 0;
   for (int i = 1; i < MAX_RESPONSE; i++) {
      if (histogram[i] > histogram[mostFrequent]) mostFrequent = i;
   }
   mostFrequent++;

   return 0;
}