Skip to content

Instantly share code, notes, and snippets.

@dertst
Created December 7, 2018 12:46
Show Gist options
  • Save dertst/641e6cad4ec9b9e72a781adce2d1028c to your computer and use it in GitHub Desktop.
Save dertst/641e6cad4ec9b9e72a781adce2d1028c to your computer and use it in GitHub Desktop.
#include "pch.h"
#include "stdio.h"
#include "string"
#include <Windows.h>
int main()
{
int num1[10];
int num2[10];
int numlen1;
int numlen2;
int res[11];
int reslen;
printf("Vvedite col-vo razryadov");
printf("\n");
scanf_s("%d", &numlen1);
printf("\n");
printf("Vvedite porazryadno chislo v pyaterichnoi sisteme");
printf("\n");
for (int i = 0; i < numlen1; i++)
{
scanf_s("%d", num1[i]);
if (num1[i] >= 5)
{
printf("vihod za predeli sistemi ischeslenia");
exit;
}
}
printf("\n");
printf("Vvedite col-vo razryadov");
printf("\n");
scanf_s("%d", &numlen2);
printf("\n");
printf("Vvedite porazryadno chislo v pyaterichnoi sisteme");
printf("\n");
for (int i = 0; i < numlen2; i++)
{
scanf_s("%d", num2[i]);
if (num2[i] >= 5)
{
printf("vihod za predeli sistemi ischeslenia");
exit;
}
}
printf("\n");
if (numlen1 > numlen2)
{
reslen = numlen1 + 1;
}
else
{
reslen = numlen2 + 1;
}
res[0] = 0;
for (int i = 1; i <reslen; i++)
{
res[i] = num1[i] + num2[i];
if (res[i] >= 5)
{
res[i - 1] = res[i - 1] + 1;
res[i] = res[i] % 5;
}
}
for (int i = 0; i < numlen2; i++)
{
printf("%d", num1[i]);
}
printf("\n");
for (int i = 0; i < numlen2; i++)
{
printf("%d", num2[i]);
}
printf("\n");
for (int i = 0; i < reslen; i++)
{
printf("%d", res[i]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment