H.I.S.C. Community
Would you like to react to this message? Create an account in a few clicks or log in to continue.


H.I.S.C. Community | 2007-2017 | Jer legende žive vječno
 
PocetnaPočetna stranicaGalleryPretraľnikRegistracijaLogin

 

 Programiranje c++

Go down 
Autor/icaPoruka
Shad0w Spect0r
№1
№1
Shad0w Spect0r

Male
Broj postova : 330
Age : 32
Mjesto : Littleville (New Gljevland)
Blog : http://dreamtoreality.blog.hr/
Registration date : 20.07.2007

Karakter
Volim: Žene Žene
Pijem: Jägermeister
Slušam: Rock

Programiranje c++ Empty
PostajNaslov: Programiranje c++   Programiranje c++ Icon_minitime27th travanj 2009, 20:47

Programiranje c++ 2942
Kod:
____________________________________zadatak 1____________________________________


#include<stdio.h>

void main()
{
int A[3][3];
int B[3][3];
int i,j;

printf("Unesite matricu 3x3:\n");

    for(i=0;i<3;i++)
    {
        for(j=0;j<3;j++)
        {
            scanf("%d",&A[i][j]);
            B[i][j]=A[i][j]*5;
        }
        }
        printf("\nMatrica A:\n\n");
    for(i=0;i<3;i++)
    {
        for(j=0;j<3;j++)
       
            printf("\t%d",A[i][j]);
            printf("\n\n");
    }
   
    printf("\nMatrica B = 5xA :\n\n");
    for(i=0;i<3;i++)
    {
        for(j=0;j<3;j++)
       
            printf("\t%d",B[i][j]);
            printf("\n\n");
    }

}

____________________________________zadatak 2____________________________________


#include<stdio.h>

void main()
{
   
    int A[3][3];
    int i,j;

printf("Unesite matricu A (3x3):\n");

    for(i=0;i<3;i++)
    {
        for(j=0;j<3;j++)
            scanf("%d",&A[i][j]);
    }
           
    printf("Unesena matrica:\n");
    for(i=0;i<3;i++)
    {
        for(j=0;j<3;j++)
       
            printf("\t%d",A[i][j]);
            printf("\n\n");
            }

    printf("\nTransponirana matrica je:\n\n");
    for(j=0;j<3;j++)
    {
        for(i=0;i<3;i++)
        printf("\t%d",A[i][j]);
        printf("\n\n");
    }
}



____________________________________zadatak 3____________________________________



#include<stdio.h>
void main()
{

    int A[3][3],B[3][3],C[3][3],D[3][3];
    int i,j,k;
    printf("\nUnesite matricu A:\n");
    for(i=0;i<3;i++)
          for(j=0;j<3;j++)
              scanf(" %d",&A[i][j]);

    printf("Unesena matrica A:\n");
    for(i=0;i<3;i++)
    {
        for(j=0;j<3;j++)
       
            printf("\t%d",A[i][j]);
            printf("\n\n");
            }

   
    printf("\nUnesite matricu B:\n");
    for(i=0;i<3;i++)
          for(j=0;j<3;j++)
              scanf(" %d",&B[i][j]);
    for(i=0;i<3;i++)
          for(j=0;j<3;j++)
              C[i][j]=A[i][j]+B[i][j];


        printf("Unesena matrica B:\n");
    for(i=0;i<3;i++)
    {
        for(j=0;j<3;j++)
       
            printf("\t%d",B[i][j]);
            printf("\n\n");
            }
     
    printf("A + B = \n");
    for(i=0;i<3;i++)
    {
        for(j=0;j<3;j++)
            printf("\t%d",C[i][j]);
        printf("\n\n");
    }

   
    for(i=0; i<3; i++)
        for(j=0; j<3; j++)
        {
            D[i][j]=0;
            for(k=0; k<3; k++)
                D[i][j]+=A[i][j]*B[j][i];
        }
        printf("A x B = \n");
        for(i=0;i<3;i++)
        {
            for(j=0;j<3;j++)
                printf("\t%d",D[i][j]);
                printf("\n\n");
        }
}


____________________________________zadatak 4____________________________________

#include <stdlib.h>
#include <stdio.h>
#include <string.h>

void main()
{
    char imena[5][20],minc[20],temp[20];
    int i,j,min=0;
    printf("Unesi 5 imena\n");
    for(i=0;i<5;i++)
        {
        printf(" %d.\t ",i);
        scanf(" %s",imena[i]);
        }
    strcpy(minc,imena[0]);
    for(i=0;i<5;i++)
    if(strcmpi(minc,imena[i])>0)
        {
        min=i;
        strcpy(minc,imena[i]);
        }
    printf("\n\nPrvi po abecedi je %d.\t %s \n",min,minc);

min=0;
strcpy(minc,imena[0]);
    for(i=0;i<5;i++)
    if(strcmpi(minc,imena[i])<0)
    {
    min=i;
    strcpy(minc,imena[i]);
    }

    printf("\n\nZadnji po abecedi je %d.\t %s \n\n",min,minc);

    for(i=0;i<5;i++)
    for(j=0;j<5;j++)
    if(strcmpi(imena[j],imena[i])>0)
        {
        strcpy(temp,imena[i]);
        strcpy(imena[i],imena[j]);
        strcpy(imena[j],temp);
        }

for(i=0;i<5;i++)
printf("%s \n",imena[i]);
}

_________________
Programiranje c++ Brutale186wa5
[Vrh] Go down
http://www.brotherhood-of-steel.mo-rpg.com
Shad0w Spect0r
№1
№1
Shad0w Spect0r

Male
Broj postova : 330
Age : 32
Mjesto : Littleville (New Gljevland)
Blog : http://dreamtoreality.blog.hr/
Registration date : 20.07.2007

Karakter
Volim: Žene Žene
Pijem: Jägermeister
Slušam: Rock

Programiranje c++ Empty
PostajNaslov: Re: Programiranje c++   Programiranje c++ Icon_minitime4th svi 2009, 21:01

Kod:
____________________________________zadatak 1________________________________________


#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <math.h>

int f1(int,int,int);
int f2(int,int,int);
float f3(int,int,int);
float f4(int,int,int);

void main(void)

{
char a=0;


int x=0, y=0,z=0;
printf("Unesite x,y,z\n");
scanf_s(" %d %d %d", &x,&y,&z);

while(a!='k' && a!='K')
{
printf("\n\t Izaberite opciju:\n");
printf("\n\t 1.x+y+z\n");
printf("\n\t 2.x*y*z\n");
printf("\n\t 3.x/y+z\n");
printf("\n\t 4.sqrt(x/y-z)\n");
a=_getche();
switch(a)
{
case '1': printf(" %d", f1(x,y,z)); break;
case '2': printf(" %d", f2(x,y,z)); break;
case '3': printf(" %f", f3(x,y,z)); break;
case '4': printf(" %f", f4(x,y,z)); break;
case 'k':
case 'K': break;
default: printf("\n Pogresan unos!!!\n");
}
}

}

int f1(int a, int b, int c)
{
printf("\n Rezultat je:\n");
return a+b+c;
}
int f2(int a, int b, int c)
{
printf("\n Rezultat je:\n");
return a*b*c;
}
float f3(int a, int b, int c)
{
printf("\n Rezultat je:\n");
return (float) a/b+c;
}
float f4(int a, int b, int c)
{
if((float)c > (float) a/b)
return -1;
else
printf("\n Rezultat je:\n");
return (float)sqrt((float)a/b-c);
}

____________________________________zadatak 2________________________________________


#include<stdio.h>
#include<string.h>

int globalna=5;

void lokalna();

void main()
{
int y=50;

void lokalna(int y);
printf("Globalna: %d\n \nLokalna: %d",globalna, y);
}


void lokalna()
{
int y=2;

}


____________________________________zadatak 3________________________________________

#include <stdio.h>
#include <math.h>

double f(double y)
{
double rez=1;
for(double i=1;i<=y;i++)
{
rez*=i;
}
return rez;
}

double exponent(double x, double n)
{
double sum = 1;
for(double i=1; i<=n; i++)
{
sum+=pow(x,i)/f(i);
}
return sum;
}


void main()
{
int x;
double suma;
printf("Unesite cijeli broj:\n");
scanf("%d", &x);

suma = exponent((double)x,5);
printf("Preciznost od 5 iznosi: %.12f\n", suma);

suma = exponent((double)x,10);
printf("Preciznost od 10 iznosi:%.12f\n", suma);

suma = exponent((double)x,50);
printf("Preciznost od 50 iznosi:%.12f\n", suma);

printf("Rezultat iznosi: %.12f\n", exp((double)x));

}


Kod:
____________________________________zadatak 1________________________________________

#include<stdio.h>
#include<string.h>
#include<math.h>



void main()
{
float a,b,c,rez;

    char znak;

    printf("Unesite 3 varijable i znak + za zbroj, * za množenje, / za djeljenje i R za korjenovanje:\n");

    scanf(%f %f %f,&a, &b, &c);

    if(znak=='+')
    {    float zbroj();
        printf("a+b+c=rez",a,b,c,(float)rez);
    }
    else if(znak=='*')
    {   
        float mnozenje();
        printf("a*b*c=rez",a,b,c,(float)rez);
    }
        else if(znak=='/')
        {
        float kvoc();
        printf("a/b+c=rez",a,b,c,(float)rez);
        }
        else if(znak=='R')
        {
        float korjen();
        printf("(a/b-c)^(1/2)=rez",a,b,c,(float)rez);
        }
        else
        printf("Pogresan unos!");


}

float zbroj(float) a,(float) b,(float)c)
{
float rez;
rez=a + b +c;
return (float)rez;
}

float mnozenje(float) a,(float) b,(float)c)
{
    float rez;
    rez=a*b*c;
    return (float)rez;
}

float kvoc((float) a,(float) b,(float)c)
{
float rez;
rez=a/b*c;
return (float)rez;
}


float korjen((float) a,(float) b,(float)c)
{
float rez;
rez=(float)sqrt(x/y-z);
return (float)rez;
}
____________________________________zadatak 2________________________________________


_________________
Programiranje c++ Brutale186wa5
[Vrh] Go down
http://www.brotherhood-of-steel.mo-rpg.com
Shad0w Spect0r
№1
№1
Shad0w Spect0r

Male
Broj postova : 330
Age : 32
Mjesto : Littleville (New Gljevland)
Blog : http://dreamtoreality.blog.hr/
Registration date : 20.07.2007

Karakter
Volim: Žene Žene
Pijem: Jägermeister
Slušam: Rock

Programiranje c++ Empty
PostajNaslov: Re: Programiranje c++   Programiranje c++ Icon_minitime18th svi 2009, 20:48

vjezba 9 incomplete Programiranje c++ 2657

Kod:

____________________________zadatak 1______________________________

//Negdje mi fali tocka-zarez u kodu, doma mi je radio

#include<stdio.h>
#include<stdlib.h>

struct _time
{
int sat;
int min;
int sec;
};

struct _time zbroj(struct _time, struct _time);

void ispis(struct _time);

void main(void)
{
struct _time a,b;

scanf("%d %d %d", &a.sat, &a.min, &a.sec);
scanf("%d %d %d", &b.sat, &b.min, &b.sec);

struct _time tbroj(struct _time T1, struct _time T2)

{
struct _time R; R.sec = 0; R.min = 0; R.sat = 0;
R.sec = T1.sec + T2.sec;

if (R.sec >= 60)
{
R.min = R.sec %60;
R.sec = R.sec %60;
}

R.min += T1.min + T2.min;

if (R.min >= 60)
{
R.sat = R.min/60;
R.min = R.min%60;
}
R.sat += T1.sat + T2.sat;
    Return R;
}

void ispis(struct _time T)

{
printf("\n\n%2d:%2d:%2d", T.sat, T.min, T.sec);

}

printf("\n\n Zbroj vremena");

ispis(a);
printf(" i");
ispis(b);
printf(" je");
ispis(Zbroj(a,b));
}

____________________________zadatak 2______________________________



#include <stdio.h>

typedef struct
{
int god, mje, dan;
}
datum;

void ispis(datum a)
{
printf("%d.%d.%d", a.dan, a.mje, a.god);
}

void dan_prije(datum a)
{
printf("Dan prije ");
ispis(a);

a.dan = a.dan - 1;

switch(a.mje)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
if(a.dan < 1)
{
a.mje--;
a.dan = a.dan + 31;
}
break;
case 4:
case 6:
case 9:
case 11:
if(a.dan < 1)
{
a.mje--;
a.dan = a.dan + 30;
}
break;
case 2:
if(a.dan < 1)
{
a.mje--;
a.dan = a.dan + 28;
}
break;
}

if(a.mje < 1)
{
a.god--;
a.mje = a.mje + 12;
}

printf(" je ");
ispis(a);
printf("\n");
}

void dan_poslije(datum a)
{
printf("Dan poslije ");
ispis(a);

a.dan = a.dan + 1;

switch(a.mje)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
if(a.dan > 31)
{
a.mje++;
a.dan = a.dan - 31;
}
break;
case 4:
case 6:
case 9:
case 11:
if(a.dan > 30)
{
a.mje++;
a.dan = a.dan - 30;
}
break;
case 2:
if(a.dan > 28)
{
a.mje++;
a.dan = a.dan - 28;
}
break;
}

if(a.mje > 12)
{
a.god++;
a.mje = a.mje - 12;
}

printf(" je ");
ispis(a);
printf("\n");
}

void main()
{
datum a;
printf("Unesi datum:\n");
scanf(" %d %d %d",&a.dan,&a.mje,&a.god);



dan_prije(a);
dan_poslije(a);
}



____________________________zadatak 3______________________________

//Nisam stigao dovršiti

#include<stdio.h>
#include<stdlib.h>

struct _time
{
int hh;
int mm;
int sec;
};

struct _date
{
int dd;
int mm;
int yyyy;
};

struct _osobe
{
char ime[10];
char prezime[10];

struct _date day;
struct _time time;
};

void main(void)
{
struct _osoba popis[5];

for(i=0;i<5;i++)
scanf("%s %s %d %d %d %d %d %d", popis[i], ime popis[i], _time.hh, _time.mm, _time.sec, _date.dd, _date.nn, _date.yyyy);
}



_________________
Programiranje c++ Brutale186wa5
[Vrh] Go down
http://www.brotherhood-of-steel.mo-rpg.com
Sponsored content




Programiranje c++ Empty
PostajNaslov: Re: Programiranje c++   Programiranje c++ Icon_minitime

[Vrh] Go down
 
Programiranje c++
[Vrh] 
Stranica 1 / 1.

Permissions in this forum:Ne moľeą odgovarati na postove.
H.I.S.C. Community :: KLUBOVI :: Caffe bar " Kerber "-
Forum(o)Bir: