Subversion Repositories svnkaklik

Compare Revisions

No changes between revisions

Regard whitespace Rev 262 → Rev 263

/programy/C/cykly/cykly.c
0,0 → 1,47
#include <stdio.h>
#include <math.h>
 
int main (void)
{
float i;
int b,x,y;
 
printf("for: \n ");
for(i=1.1;i<10;i+=1.1)
{
printf("%2.1f ",i);
}
 
printf("\nwhile: \n ");
i=1.1;
while(i<10)
{
printf("%2.1f ",i);
i+=1.1;
}
 
printf("\ndowhile: \n ");
i=1.1;
do
{
printf("%2.1f ",i);
i+=1.1;
}
while (i<10);
printf("\nAbeceda: \n ");
for(b='a';b<='z';b++)
{
printf("%c ",b);
}
printf("\nNasobilka: \n ");
for(y=1;y<=10;y++)
{
for(x=1;x<=10;x++)
{
printf("%4d ",(x*y));
}
printf("\n ");
}
}
/programy/C/cykly/cykly.exe
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/programy/C/nahoda/nahoda.c
0,0 → 1,40
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
 
int rnd (int max)
{
return ( (int) (max * (rand()/(RAND_MAX+1.0))));
}
 
void init_rnd(void)
{
time_t t;
unsigned int seed;
time(&t);
seed=(unsigned int) t;
srand(seed);
}
 
int main()
{
 
int i=1,hledane,pokus;
init_rnd();
printf("program uhodne cislo od 0 do 100 \n ");
hledane=rnd(10);
do
{
printf("Pokus cislo %d ",i);
scanf("%d", &pokus);
i++;
if (pokus > hledane) printf("Zadane cislo je vetsi nez hledane \n ");
if (pokus < hledane) printf("Zadane cislo je mensi nez hledane \n ");
else printf("Spravne cislo bylo nalezeno \n ");
}
while (pokus != hledane);
}
/programy/C/nahoda/nahoda.exe
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/programy/C/opis/opis.c
0,0 → 1,43
/////////////////////////////////////////////////////////////////
// Program opise zadany text az do chvile, nez narazi na tecku.
/////////////////////////////////////////////////////////////////
 
#include <stdlib.h>
#include <stdio.h>
 
 
int clear_buffer()
{
int i=0;
 
while (getchar() != '\n') i++;
return i;
}
 
 
int main()
{
 
int c;
 
printf("Program po stisknutí Enteru opíše zadaný vstup \n");
/*Prvni zpusob reseni */
do
{
c=getchar();
putchar(c);
}
while (c != '.');
printf("\n Pocet smazanych znaku %d \n",clear_buffer());
/* Druhy zpusob reseni*/
while ((c=getchar()) != '.') putchar(c);
printf("\n Pocet smazanych znaku %d \n",clear_buffer());
/* treti zpusob reseni*/
while(putchar(getchar()) != '.');
}
/programy/C/opis/opis.exe
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/programy/C/rovnice/rovnice.c
7,20 → 7,34
printf("program vyresi rovnici ve tvaru Ax^2 + Bx + C = 0");
// zadej hodnoty
printf("\n Zadej hodnotu A= ");
scanf("%f",&a);
scanf("%d",&a);
printf("\n Zadej hodnotu B= ");
scanf("%f",&b);
scanf("%d",&b);
printf("\n Zadej hodnotu C= ");
scanf("%f",&c);
scanf("%d",&c);
if(a==0)
{
if(b==0) printf("rovnice nema reseni v realnych cislech"); // rovnice je neresitelna
else printf("X=%d",(-c/b)); // jedna se o linearni rovnici
if(b==0) printf("rovnice nema reseni."); // rovnice je neresitelna
else printf("X=%f",-(float)c/b ); // jedna se o linearni rovnici
}
else
{ // rovnice ma reseni
d=sqrt(b*b-4*a*c);
printf("discriminant rovnice D=%f",d);
d=((b*b)-(4*a*c));
printf("\n discriminant rovnice D=%d",d);
if (d>0)
{
printf("\n rovnice ma reseni X1=%f X2=%f",( ((float)-b)+sqrt(d))/2*a,((float)-b)-sqrt(d))/2*a;
}
if (d==0)
{
printf("\n rovnice ma jeden koren X=%f",(((float)-b)/2*a));
}
if (d<0)
{
printf("\n reseni rovnice lezi v rovine komplexnich cisel.");
printf("\n X1=%f X2=%f");
}
}
}
/programy/C/rovnice/rovnice.exe
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property