Commit a861c772 by trkall

5.aprill

parent a968b381
#include <stdio.h>
unsigned int disjuktsioon(unsigned int, unsigned int);
unsigned int konjuktsioon(unsigned int, unsigned int);
unsigned int nihevasakule(unsigned int, int);
unsigned int niheparemale(unsigned int, int);
void printBits(unsigned int);
int main() {
unsigned int a;
unsigned int b;
unsigned int y;
int c;
int d;
int i = 0;
printf("Sisestage esimese arvu v22rtus\n");
scanf("%u", &a);
printf("Sisestage teise arvu v22rtus\n");
scanf("%u", &b);
while(i == 0)
{
printf("\nMillist tehet soovite?\n[1]disjunktsioon\n[2]konjuktsioon\n[3]nihevasakule\n[4]niheparemale\n[5]lahku programmist\n");
scanf("%d", &c);
switch(c)
{
case 1:
y = disjuktsioon(a, b);
break;
case 2:
y = konjuktsioon(a, b);
break;
case 3:
printf("Mitu j2rku nihutada?\n");
scanf("%d", &d);
y = nihevasakule(a, d);
break;
case 4:
printf("Mitu j2rku nihutada?\n");
scanf("%d", &d);
y = niheparemale(a, d);
break;
case 5:
i = 1;
break;
}
printBits(y);
}
return 0;
}
void printBits(unsigned int num){
unsigned int size = sizeof(unsigned int);
unsigned int maxPow = 1<<(size*8-1);
// printf("MAX POW : %u\n",maxPow);
int i=0,j;
for(;i<size*8;++i){
// print last bit and shift left.
printf("%u ",!!(num&maxPow));
num = num<<1;
}
}
unsigned int disjuktsioon(unsigned int a, unsigned int b)
{
return a | b;
}
unsigned int konjuktsioon(unsigned int a, unsigned int b)
{
return a & b;
}
unsigned int nihevasakule(unsigned int a, int x)
{
return a << x;
}
unsigned int niheparemale(unsigned int a, int x)
{
return a >> x;
}
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
int L = 15;
int MAX = 1;
int MIN = 0;
/* /*
1. klaviatuurilt sisestatakse reaalarvulised X (|X|<1) ja e (0<e<1); 1. klaviatuurilt sisestatakse reaalarvulised X (|X|<1) ja e (0<e<1);
...@@ -32,3 +35,23 @@ int main(void) ...@@ -32,3 +35,23 @@ int main(void)
} }
double aste(double x, int y)
{
int i;
for (i = 1;i < y; i++)
{
x*=x;
}
return x;
}
double absolutevodka(double x)
{
if( x < 0)
{
x *= -1;
}
return x;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment