#include <iostream>
#include <ctime>
#include <stdio.h>
int main()
{
setlocale(LC_ALL, "Ukr");
int n = 3, m = 3;
printf("Кiлькiсть рядкiв матрицi = ");
scanf("%d", &n);
printf("Кiлькiсть стовпцiв матрицi = ");
scanf("%d", &m);
int mat[n][m];
srand(time(NULL));
printf("Була:\n ");
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++)
mat[i][j] = rand() % 21 - 10;
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
printf("%d ",mat[i][j]);
printf("\n");
}
printf("Cтала:\n ");
for (int i = 0; i < n; i++)
{
int* temp = new int[n];
temp[i] = mat[n - 1][i];
mat[n - 1][i] = mat[i][0];
mat[i][0] = temp[i];
}
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
printf("%d ",mat[i][j]);
printf("\n");
}
return 0;
}
from tkinter import *
from math import*
root = Tk()
root.title("Задание 2")
root.geometry("550x250")
def summa():
n=EntryN.get()
n=int(n)
a=EntryA.get()
a=int(a)
d=EntryD.get()
d=int(d)
m=EntryM.get()
m=int(m)
s=0
for i in range(1,4):
s+=i + m
pr=1
for j in range(1,4):
pr*=j+d
res=n*(a/pr+s/m)
EntryS.configure(text='y = {}'.format(res))
#EntryS.delete(0,END)
#EntryS.insert(0,res)
Label(root, width=15, text=" n =",font="Times 14").grid(row=1, column=5, sticky=W)
Label(root, width=15, text=" a =",font="Times 14").grid(row=2, column=5, sticky=W)
Label(root, width=15, text=" d =",font="Times 14").grid(row=3, column=5, sticky=W)
Label(root, width=15, text=" m =",font="Times 14").grid(row=4, column=5, sticky=W)
EntryN = Entry(root, width=15, font="Times 14")
EntryA = Entry(root, width=15, font="Times 14")
EntryD = Entry(root, width=15, font="Times 14")
EntryM = Entry(root, width=15, font="Times 14")
#EntryS = Entry(root, width=25, font="Times 14")
EntryS = Label(root)
EntryS.grid(column=5, row=5)
EntryN.grid(row=1, column=6, sticky=E)
EntryA.grid(row=2, column=6, sticky=E)
EntryD.grid(row=3, column=6, sticky=E)
EntryM.grid(row=4, column=6, sticky=E)
# файл с формулой, если отличается - укажите свой
img = PhotoImage(file="d:/f1.gif")
label = Label(root, image=img)
label.image_ref = img
label.grid(column=9, row=0)
but = Button(root, text="Вывести сумму", width=20, font="Times 10", command=summa)
but.grid(row=5, column=9, sticky=E)
root.mainloop()