1.Реализовать программу, выводящую n-ый член последовательности, заданной: , где
#include
#include
using namespace std;
int f(int n) {
if (n = 0) { return 1; }
if (n = 1) { return 4; }
return 3*f(n - 1) - f(n - 2);
}
int main()
{
int i;
cin >> i;
cout << f(i);
system("PAUSE");
}
2. Дана матрица, реализовать процедуры транспонирования и антисимметризации.
Program prog
integer, allocatable::a(:,:)
integer, allocatable::a1(:,:)
integer, allocatable::buf(:)
real, allocatable::as(:,:)
integer, allocatable::at(:,:)
integer size
write (*,*) " Vvedite razmer"
read (*,*) size
allocate(a(size,size))
allocate(a1(size,size))
allocate(as(size,size))
allocate(at(size,size))
do i=1, size
do j=1, size
a(i,j)=mod(irand(0)50)-50
end do
end do
at=traspouse(a)
!do i=1,size
!buf=a(i,:)
!a(i,:)=a(:,i)
!a(:,i)=buf
!end do
as=0.5*(a-at)
write(*,101) a
write(*,101) at
write(*,100) as
pause
100 format(f6.2,\)
101 format(i2,\)
end