2024-11-06 09:41:00 +04:00
|
|
|
|
#define _CRT_SECURE_NO_WARNINGS
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <Windows.h>
|
|
|
|
|
|
|
|
|
|
#define MAX_N 8
|
|
|
|
|
#define MAX_M 10
|
|
|
|
|
|
|
|
|
|
int arr[MAX_N][MAX_M];
|
|
|
|
|
int arr1[MAX_N][MAX_M*2];
|
|
|
|
|
int n = 0;
|
|
|
|
|
int m = 0;
|
|
|
|
|
int i, j, k, column;
|
|
|
|
|
|
|
|
|
|
void keyboardInput();
|
|
|
|
|
void print();
|
|
|
|
|
void fillIx10();
|
|
|
|
|
void fillZero();
|
|
|
|
|
void randFill0_9();
|
|
|
|
|
void NechetX10();
|
|
|
|
|
void Krat10();
|
|
|
|
|
void save();
|
|
|
|
|
void load();
|
|
|
|
|
void deleteRow(int delRow);
|
|
|
|
|
void ChetNet();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void main() {
|
|
|
|
|
SetConsoleCP(1251);
|
|
|
|
|
SetConsoleOutputCP(1251);
|
|
|
|
|
int item;
|
|
|
|
|
do {
|
|
|
|
|
printf("\n");
|
|
|
|
|
print();
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:\n");
|
|
|
|
|
printf("------------------------------\n");
|
|
|
|
|
printf("1: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> i * 10 + j \n");
|
|
|
|
|
printf("2: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
|
|
|
|
|
printf("3: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
|
|
|
|
|
printf("4: <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> 10 <20><><EFBFBD>\n");
|
|
|
|
|
printf("5: <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 10 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> 10 <20><><EFBFBD>\n");
|
|
|
|
|
printf("6: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
|
|
|
|
|
printf("7: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
|
|
|
|
|
printf("8: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
|
|
|
|
|
printf("9: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
|
|
|
|
|
printf("10: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
|
|
|
|
|
printf("11: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
|
|
|
|
|
printf("\n");
|
|
|
|
|
printf("0: <20><><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> >>>>>> ");
|
|
|
|
|
|
|
|
|
|
scanf_s("%d", &item);
|
|
|
|
|
|
|
|
|
|
switch (item) {
|
|
|
|
|
case 1:
|
|
|
|
|
|
|
|
|
|
fillIx10();
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
fillZero();
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
{
|
|
|
|
|
randFill0_9();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 4:
|
|
|
|
|
{
|
|
|
|
|
NechetX10();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 5:
|
|
|
|
|
{
|
|
|
|
|
Krat10();
|
|
|
|
|
}break;
|
|
|
|
|
case 6:
|
|
|
|
|
{
|
|
|
|
|
keyboardInput();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 7:
|
|
|
|
|
{
|
|
|
|
|
save();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 8:
|
|
|
|
|
{
|
|
|
|
|
load();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 9:
|
|
|
|
|
|
|
|
|
|
int num;
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: ");
|
|
|
|
|
scanf_s("%d", &num);
|
|
|
|
|
deleteRow(num);
|
|
|
|
|
print();
|
|
|
|
|
break;
|
|
|
|
|
case 10:
|
|
|
|
|
{
|
|
|
|
|
int a = 0;
|
|
|
|
|
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = ");
|
|
|
|
|
scanf_s("%d", &a);
|
|
|
|
|
for (int i = 0; i < n; i++) {
|
|
|
|
|
for (int j = a; j < (m + 1); j++) {
|
|
|
|
|
arr[i][m] = arr[i][a];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
m++;
|
|
|
|
|
for (int i = 0; i < n; i++) {
|
|
|
|
|
for (int j = 0; j < m; j++) {
|
|
|
|
|
printf("%d ", arr[i][j]);
|
|
|
|
|
}
|
|
|
|
|
printf("\n");
|
|
|
|
|
}
|
|
|
|
|
}break;
|
|
|
|
|
case 11:
|
|
|
|
|
{
|
|
|
|
|
ChetNet();
|
|
|
|
|
}break;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} while (item != 0);
|
|
|
|
|
}
|
|
|
|
|
void keyboardInput() {
|
|
|
|
|
printf("n = ");
|
|
|
|
|
scanf_s("%d", &n);
|
|
|
|
|
|
|
|
|
|
printf("m = ");
|
|
|
|
|
scanf_s("%d", &m);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
printf("input values: ");
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < n; i++) {
|
|
|
|
|
for (int j = 0; j < m; j++) {
|
|
|
|
|
scanf_s("%d", &arr[i][j]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
void print() {
|
|
|
|
|
printf("!!!! print() !!!!\n");
|
|
|
|
|
for (int i = 0; i < n; i++) {
|
|
|
|
|
for (int j = 0; j < m; j++) {
|
|
|
|
|
printf("%3d ", arr[i][j]);
|
|
|
|
|
}
|
|
|
|
|
printf("\n");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
void fillIx10() {
|
|
|
|
|
printf("!!!! fillIx10() !!!!\n");
|
|
|
|
|
for (int i = 0; i < n; i++) {
|
|
|
|
|
for (int j = 0; j < m; j++) {
|
|
|
|
|
arr[i][j] = i * 10 + j;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
void fillZero() {
|
|
|
|
|
printf("!!!! fillZero() !!!!\n");
|
|
|
|
|
for (int i = 0; i < n; i++) {
|
|
|
|
|
for (int j = 0; j < m; j++) {
|
|
|
|
|
arr[i][j] = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
void randFill0_9() {
|
|
|
|
|
printf("!!!! randFill0_9() !!!!\n");
|
|
|
|
|
for (int i = 0; i < n; i++) {
|
|
|
|
|
for (int j = 0; j < m; j++) {
|
|
|
|
|
arr[i][j] = rand() % 10;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
void NechetX10() {
|
|
|
|
|
printf("!!!! NechetX10() !!!!\n");
|
|
|
|
|
for (int i = 0; i < n; i++) {
|
|
|
|
|
for (int j = 0; j < m; j++) {
|
|
|
|
|
if (arr[i][j] % 2 != 0)
|
|
|
|
|
{
|
|
|
|
|
arr[i][j] *= 10;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
void Krat10() {
|
|
|
|
|
printf("!!!! Krat10() !!!!\n");
|
|
|
|
|
for (int i = 0; i < n; i++) {
|
|
|
|
|
for (int j = 0; j < m; j++) {
|
|
|
|
|
if (arr[i][j] % 10 == 0)
|
|
|
|
|
{
|
|
|
|
|
arr[i][j] /= 10;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
void save() {
|
|
|
|
|
FILE* fout = fopen("d:\\zagryzka s interneta\\arr1.txt", "wt");
|
|
|
|
|
if (fout == NULL) {
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fprintf(fout, "%d ", n);
|
|
|
|
|
fprintf(fout, "%d\n", m);
|
|
|
|
|
for (int i = 0; i < n; i++) {
|
|
|
|
|
for (int j = 0; j < m; j++) {
|
|
|
|
|
fprintf(fout, "%d ", arr[i][j]);
|
|
|
|
|
}
|
|
|
|
|
fprintf(fout, "\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fclose(fout);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
void load() {
|
|
|
|
|
|
|
|
|
|
FILE* fin = fopen("d:\\zagryzka s interneta\\arr1.txt", "rt");
|
|
|
|
|
if (fin == NULL) {
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fscanf(fin, "%d", &n);
|
|
|
|
|
fscanf(fin, "%d", &m);
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < n; i++) {
|
|
|
|
|
for (int j = 0; j < m; j++) {
|
|
|
|
|
fscanf(fin, "%d", &arr[i][j]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fclose(fin);
|
|
|
|
|
}
|
2024-11-06 09:43:23 +04:00
|
|
|
|
//void deleteRow(int delRow) {
|
|
|
|
|
// printf("!!!! deleteRow(%d) !!!!\n", delRow);
|
|
|
|
|
// for (int i = delRow; i < n - 1; i++) {
|
|
|
|
|
// for (int j = 0; j < m; j++) {
|
|
|
|
|
// arr[i][j] = arr[i + 1][j];
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// n--;
|
|
|
|
|
//}
|
|
|
|
|
//
|
|
|
|
|
//void ChetNet() {
|
|
|
|
|
// printf("!!!! ChetNet() !!!!\n");
|
|
|
|
|
// for (int i = 0; i < n; i++) {
|
|
|
|
|
// for (int j = 0; j < m; j++) {
|
|
|
|
|
// if (arr[i][j] % 2 == 1) {
|
|
|
|
|
// arr[i][j] = 0;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//}
|
2024-11-06 09:41:00 +04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|