Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace ClassLibrary5 {
- void Class1::outputText(int value, TextBox^ t) {
- t->Text = Convert::ToString(value);
- }
- void Class1::outputArray(int arrLen, int* arr, DataGridView^ grid) {
- grid->ColumnCount = arrLen;
- grid->RowCount = 2;
- int width = 0;
- for (int i = 0; i < arrLen; i++) {
- grid->Rows[0]->Cells[i]->Value = "[" + Convert::ToString(i) + "]";
- grid->Rows[1]->Cells[i]->Value = arr[i];
- width += grid->Columns[i]->Width;
- }
- if (width > 410) {
- grid->Width = 410;
- }
- else
- {
- grid->Width = width;
- }
- }
- void Class1::generateArray(int arrLen, int* arr) {
- for (int i = 0; i < arrLen; i++) {
- arr[i] = int(rand() % 1001);
- }
- }
- int Class1::getCount(int arrLen, int* arr) {
- int count = 0;
- for (int i = 0; i < arrLen - 1; i++) {
- if ((arr[i] - arr[i + 1]) % 7 != 0) {
- count++;
- }
- }
- return count;
- }
- void Class1::replaceElements(int arrLen, int count, int* arr, int* newArr, int &j) {
- int elementCount = 0;
- for (int i = 0; i < arrLen; i++) {
- if (arr[i] > count) {
- elementCount++;
- }
- }
- newArr[elementCount];
- for (int i = 0; i < arrLen; i++) {
- if (arr[i] > count) {
- newArr[j] = arr[i];
- j++;
- }
- }
- for (int i = 0; i < arrLen; i++) {
- if (arr[i] % 7 == 0) {
- arr[i] = count;
- }
- }
- }
- void Class1::sort6(int arrLen, int* arr) {
- for (int i = 1; i < arrLen; i++) {
- int j = i - 1;
- int x = arr[i];
- while (arr[j] > x && x >= 0) {
- arr[j + 1] = arr[j];
- j--;
- }
- arr[j + 1] = x;
- }
- }
- void Class1::SortNumber5(int arrLen, int* arr) {
- int MaxValue = 0;
- int MinValue = 1000;
- int indexMax = -1;
- int indexMin = -1;
- for (int i = 0; i < arrLen; i++) {
- if (arr[i] > MaxValue) {
- MaxValue = arr[i];
- indexMax = i;
- }
- else if (arr[i] < MinValue) {
- MinValue = arr[i];
- indexMin = i;
- }
- }
- arr[indexMin] = MaxValue;
- arr[indexMax] = MinValue;
- }
- void Class1::sort92(int arrLen, int* arr) {
- int flag = 1;
- for (int i = arrLen - 1; i >= 0; i--) {
- if (flag == 1) {
- flag = 0;
- for (int j = 1; j <= i; j++) {
- if (arr[j] > arr[j - 1]) {
- int temp = arr[j];
- arr[j] = arr[j - 1];
- arr[j - 1] = temp;
- flag = 1;
- }
- }
- }
- else {
- return;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement