Skip to content

Instantly share code, notes, and snippets.

@dertst
Created November 26, 2018 18:50
Show Gist options
  • Save dertst/30507c360a9b79cc3101e5efacaeb9dc to your computer and use it in GitHub Desktop.
Save dertst/30507c360a9b79cc3101e5efacaeb9dc to your computer and use it in GitHub Desktop.
готовая лаба по инфе
#include "pch.h"
#include <cstdio>
#include <conio.h>
#include <stdio.h>
#include <Windows.h>
#include <iostream>
int main()
{
char a[100][100];
printf("Press Key");
printf("\n");
int key1;
scanf_s("%d", &key1);
int size1;
FILE *f;
fopen_s(&f, "C:\\temp\\long1.txt", "rt");
fscanf_s(f, "%d", &size1);
fclose(f);
fopen_s(&f, "C:\\temp\\skitala1.txt", "rt");
for (int i = 0; i < key1; i++)
{
for (int j = 0; j < size1; j++)
{
fscanf_s(f, "%c", &a[i][j]);
printf("%c", a[i][j]);
}
printf("\n");
}
printf("\n");
fclose(f);
printf("Zashifrovannoe soobshenie");
printf("\n");
for (int j = 0; j < size1; j++)
{
for (int i = 0; i < key1; i++)
{
printf("%c", a[i][j]);
}
}
printf("\n");
char b[100][100];
printf("Press Key");
printf("\n");
int key2;
scanf_s("%d", &key2);
int size2;
fopen_s(&f, "C:\\temp\\long2.txt", "rt");
fscanf_s(f, "%d", &size2);
fclose(f);
fopen_s(&f, "C:\\temp\\skitala2.txt", "rt");
for (int i = 0; i < key2; i++)
{
for (int j = 0; j < size2; j++)
{
fscanf_s(f, "%c", &b[i][j]);
printf("%c", b[i][j]);
}
printf("\n");
}
printf("\n");
fclose(f);
printf("Zashifrovannoe soobshenie");
printf("\n");
for (int j = 0; j < size2; j++)
{
for (int i = 0; i < key2; i++)
{
printf("%c", b[i][j]);
}
}
printf("\n");
char c[100][100];
int key3;
printf("Press Key");
printf("\n");
scanf_s("%d", &key3);
int size3;
fopen_s(&f, "C:\\temp\\long3.txt", "rt");
fscanf_s(f, "%d", &size3);
fclose(f);
fopen_s(&f, "C:\\temp\\skitala3.txt", "rt");
for (int i = 0; i < key3; i++)
{
for (int j = 0; j < size3; j++)
{
fscanf_s(f, "%c", &c[i][j]);
printf("%c", c[i][j]);
}
printf("\n");
}
printf("\n");
fclose(f);
printf("Zashifrovannoe soobshenie");
printf("\n");
for (int j = 0; j < size3; j++)
{
for (int i = 0; i < key3; i++)
{
printf("%c", c[i][j]);
}
}
printf("\n");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment