3475


1.

Kod:

w c++:

#include <iostream>
#include <stdlib.h>

using namespace std;

int main(){

int n=4;
int b[4][4], tmp, i, j, max;
srand(time(NULL));

for(i=0; i<n; i++){
    for(j=0; j<n; j++){
        b[i][j]=rand()%9;
        cout << b[i][j] << " ";
    }
cout << endl;
}


for(i=n; i!=0; i--){
    tmp=1;
        for(j=0; j<i; j++){
            tmp*=b[i-j-1][j];
        }
if(i==n || tmp > max){
    max=tmp;
}
}
cout << endl << "Max = " << max << endl;

return 0;
}

ewentualnie sam algorytm:
for(i=0; i<n; i++){
    tmp=1;
        for(j=0; j<n-i; j++){
            tmp*=b[i+j][n-j-1];
        }
if(i==0 || tmp > max){
    max=tmp;
}
}


2.

Kod:


double y, e //dane

double w, l, m, b=1, by;
l=1;
m=1;
by=1;
int i=0;
w=(l/m)*by;
while(w>e) {
if(i==0) { l=5; m=2; i++; }
else { l=l*(l+2); m=m*(m+2); }
by=by*y;
w=(l/m)*by;
b=b+pow(-1, i)*w;
}

3.

Kod:

int m; //dane
int i;
dounle b;
for(i=1; i<=m; i=i*2) {
if(i==1) b=1;
else  b=i+3*b;
}


4.

Kod:

Zrobione podpunkty do 4:

//1
void wypisz_liste(struct element *p)
{
    struct element *temp;
    temp=p;
    printf("Elementy listy:\n");
    while(temp!=NULL)
    {

                 printf("%d\t", temp->wartosc);
                 temp=temp->nast;
    }
    printf("\n");
}



//2
void dziel(struct element **l, struct element **p, struct **w)
{
    struct element *a, *b;
    a=*l;
    b=*p;
    while(a->nast != b->nast)
    {
        a=a->nast;
        b=b->nast;
    }
(*w)=a->nast;
a->nast=NULL;
b->nast=NULL;
}

//3
void cykl(struct **w)
{
    struct element *a;
    a=*w;
    while(a->nast != NULL)
    {
        a=a->nast;
    }
a->nast=(*w);
}



Wyszukiwarka

Podobne podstrony:
3475
3475
200403 3475
3475
3475
3475
3475
3475(1)
3475
uchwala sp 3475

więcej podobnych podstron