zadatak166.

Nenadov kod

#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
int n,br=0;
cin >>n;
int a[n],b[n],c[n],m[10][10];
for(int x=0;x<n;x++)
{
cin >> a[x] >> b[x] >> c[x];
a[x]–; b[x]–;
for(int i=0;i<10;i++)
for(int j=0;j<10;j++)
if(i>a[x] && i<=a[x]+c[x] && j>b[x] && j<=b[x]+c[x]) if(m[i][j]!=1){m[i][j]=1;br++;} }
cout << br << endl;
int g=0;
for(int x=9;x>0;x–)
{
for(int i=0;i<=10-x;i++)
{ for(int j=0;j<=10-x;j++)
{ g=x; for(int k=i;k<i+x;k++)
{ for(int l=j;l<j+x;l++)
{ if(m[k][l]==1){g=0;break;} }
if(g==0)break; }
if(g==x)
{cout << g << endl;
return 0;}
}
} }
system(„PAUSE“);
return EXIT_SUCCESS;
}

 

Markov kod

#include <cstdlib>
#include <iostream>
using namespace std;
int main()
{ int n,v,h,d,br,i,j,p1,p,k;
cout<<„Unesi broj postera: „;
cin>>n;
int x[100];
for (i=1;i<=100;i++)
{x[i]=i;} while (n>0)
{cout<<„Unesite udaljenost postera od lijevog donjeg ugla zida: „<<endl;
cout<<„-vertikalno: „; cin>>v; cout<<„-horizontalno: „;
cin>>h; cout<<„Unesite dimenziju postera: „<<endl;
cin>>d; p1=v*10+h; br=d;
while (br>0)
{for (j=1;j<=d;j++)
{p1=p1+1; for (i=1;i<=100;i++)
if (p1==x[i]) x[i]=0;} p1=p1+(10-d);
br=br-1;} n=n-1;} p=0; for (i=1;i<=100;i++)
if (x[i]!=0) p=p+1; cout<<„Povrsina prekrivena posterima je „<<100-p<<“ m2″<<endl;
cout<<„Najveci poster koji se moze staviti je „;
if (p==100) {cout<<„10 m „<<endl; goto kraj;}
for (k=1;k<=12;k++)
{if ((k%10<2)&&(k%10!=0)&&(x[k]*x[k+1]*x[k+2]*x[k+3]*x[k+4]*x[k+5]*x[k+6]*x[k+7]*x[k+8]!=0)&&
(x[k+10]*x[k+11]*x[k+12]*x[k+13]*x[k+14]*x[k+15]*x[k+16]*x[k+17]*x[k+18]!=0)&&
(x[k+20]*x[k+21]*x[k+22]*x[k+23]*x[k+24]*x[k+25]*x[k+26]*x[k+27]*x[k+28]!=0)&&
(x[k+30]*x[k+31]*x[k+32]*x[k+33]*x[k+34]*x[k+35]*x[k+36]*x[k+37]*x[k+38]!=0)&&
(x[k+40]*x[k+41]*x[k+42]*x[k+43]*x[k+44]*x[k+45]*x[k+46]*x[k+47]*x[k+48]!=0)&&
(x[k+50]*x[k+51]*x[k+52]*x[k+53]*x[k+54]*x[k+55]*x[k+56]*x[k+57]*x[k+58]!=0)&&
(x[k+60]*x[k+61]*x[k+62]*x[k+63]*x[k+64]*x[k+65]*x[k+66]*x[k+67]*x[k+68]!=0)&&
(x[k+70]*x[k+71]*x[k+72]*x[k+73]*x[k+74]*x[k+75]*x[k+76]*x[k+77]*x[k+78]!=0)&&
(x[k+80]*x[k+81]*x[k+82]*x[k+83]*x[k+84]*x[k+85]*x[k+86]*x[k+87]*x[k+88]!=0)&&(k+88<=100))
{cout<<„9 m „<<endl;
goto kraj;}}
for (k=1;k<=23;k++)
{if ((k%10<3)&&(k%10!=0)&&(x[k]*x[k+1]*x[k+2]*x[k+3]*x[k+4]*x[k+5]*x[k+6]*x[k+7]!=0)&&
(x[k+10]*x[k+11]*x[k+12]*x[k+13]*x[k+14]*x[k+15]*x[k+16]*x[k+17]!=0)&&
(x[k+20]*x[k+21]*x[k+22]*x[k+23]*x[k+24]*x[k+25]*x[k+26]*x[k+27]!=0)&&
(x[k+30]*x[k+31]*x[k+32]*x[k+33]*x[k+34]*x[k+35]*x[k+36]*x[k+37]!=0)&&
(x[k+40]*x[k+41]*x[k+42]*x[k+43]*x[k+44]*x[k+45]*x[k+46]*x[k+47]!=0)&&
(x[k+50]*x[k+51]*x[k+52]*x[k+53]*x[k+54]*x[k+55]*x[k+56]*x[k+57]!=0)&&
(x[k+60]*x[k+61]*x[k+62]*x[k+63]*x[k+64]*x[k+65]*x[k+66]*x[k+67]!=0)&&
(x[k+70]*x[k+71]*x[k+72]*x[k+73]*x[k+74]*x[k+75]*x[k+76]*x[k+77]!=0)&&
(k+77<=100)) {cout<<„8 m „<<endl; goto kraj;}}
for (k=1;k<=34;k++)
{if ((k%10<4)&&(k%10!=0)&&(x[k]*x[k+1]*x[k+2]*x[k+3]*x[k+4]*x[k+5]*x[k+6]!=0)&&
(x[k+10]*x[k+11]*x[k+12]*x[k+13]*x[k+14]*x[k+15]*x[k+16]!=0)&&
(x[k+20]*x[k+21]*x[k+22]*x[k+23]*x[k+24]*x[k+25]*x[k+26]!=0)&&
(x[k+30]*x[k+31]*x[k+32]*x[k+33]*x[k+34]*x[k+35]*x[k+36]!=0)&&
(x[k+40]*x[k+41]*x[k+42]*x[k+43]*x[k+44]*x[k+45]*x[k+46]!=0)&&
(x[k+50]*x[k+51]*x[k+52]*x[k+53]*x[k+54]*x[k+55]*x[k+56]!=0)&&
(x[k+60]*x[k+61]*x[k+62]*x[k+63]*x[k+64]*x[k+65]*x[k+66]!=0)&&(k+66<=100))
{cout<<„7 m „<<endl; goto kraj;}}
for (k=1;k<=45;k++)
{if ((k%10<5)&&(k%10!=0)&&(x[k]*x[k+1]*x[k+2]*x[k+3]*x[k+4]*x[k+5]!=0)&&
(x[k+10]*x[k+11]*x[k+12]*x[k+13]*x[k+14]*x[k+15]!=0)&& (x[k+20]*x[k+21]*x[k+22]*x[k+23]*x[k+24]*x[k+25]!=0)&&
(x[k+30]*x[k+31]*x[k+32]*x[k+33]*x[k+34]*x[k+35]!=0)&& (x[k+40]*x[k+41]*x[k+42]*x[k+43]*x[k+44]*x[k+45]!=0)&&
(x[k+50]*x[k+51]*x[k+52]*x[k+53]*x[k+54]*x[k+55]!=0)&&(k+55<=100))
{cout<<„6 m „<<endl;
goto kraj;}}
for (k=1;k<=56;k++) {if ((k%10<6)&&(k%10!=0)&&(x[k]*x[k+1]*x[k+2]*x[k+3]*x[k+4]!=0)&&
(x[k+10]*x[k+11]*x[k+12]*x[k+13]*x[k+14]!=0)&& (x[k+20]*x[k+21]*x[k+22]*x[k+23]*x[k+24]!=0)&&
(x[k+30]*x[k+31]*x[k+32]*x[k+33]*x[k+34]!=0)&& (x[k+40]*x[k+41]*x[k+42]*x[k+43]*x[k+44]!=0)&&(k+44<=100))
{cout<<„5 m „<<endl;
goto kraj;}}
for (k=1;k<=67;k++)
{if ((k%10<7)&&(k%10!=0)&&(x[k]*x[k+1]*x[k+2]*x[k+3]!=0)&& (x[k+10]*x[k+11]*x[k+12]*x[k+13]!=0)&&
(x[k+20]*x[k+21]*x[k+22]*x[k+23]!=0)&& (x[k+30]*x[k+31]*x[k+32]*x[k+33]!=0)&&(k+33<=100))
{cout<<„4 m „<<endl;
goto kraj;}}
for (k=1;k<=78;k++)
{if ((k%10<8)&&(k%10!=0)&&(x[k]*x[k+1]*x[k+2]!=0)&& (x[k+10]*x[k+11]*x[k+12]!=0)&&
(x[k+20]*x[k+21]*x[k+22]!=0)&&(k+22<=100))
{cout<<„3 m „<<endl;
goto kraj;}}
for (k=1;k<=89;k++) {if ((k%10<9)&&(k%10!=0)&&(x[k]*x[k+1]!=0)&& (x[k+10]*x[k+11]!=0)&&(k+11<=100))
{cout<<„2 m „<<endl;
goto kraj;}}
for (k=1;k<100;k++)
{if ((k%10<=0)&&(x[k]!=0))
{cout<<„1 m „<<endl;
goto kraj;}}
kraj: system(„PAUSE“);
return EXIT_SUCCESS; }

Ostavite odgovor

Popunite detalje ispod ili pritisnite na ikonicu da biste se prijavili:

WordPress.com logo

Komentarišet koristeći svoj WordPress.com nalog. Odjavite se /  Promeni )

Google photo

Komentarišet koristeći svoj Google nalog. Odjavite se /  Promeni )

Slika na Tviteru

Komentarišet koristeći svoj Twitter nalog. Odjavite se /  Promeni )

Fejsbukova fotografija

Komentarišet koristeći svoj Facebook nalog. Odjavite se /  Promeni )

Povezivanje sa %s