diff --git a/2015-2016/V/10/02/task1.c b/2015-2016/V/10/02/task1.c new file mode 100644 index 00000000..4ef99ac1 --- /dev/null +++ b/2015-2016/V/10/02/task1.c @@ -0,0 +1,12 @@ +#include +int main() +{ + int i; + for(i=0;i<=255;i++) + { + printf("%c: %d\n",i,i); + + } + + return 0; +} diff --git a/2015-2016/V/10/02/task2.c b/2015-2016/V/10/02/task2.c new file mode 100644 index 00000000..d729c0fc --- /dev/null +++ b/2015-2016/V/10/02/task2.c @@ -0,0 +1,30 @@ +#include +#include +int main() +{ + char dumi[100]; + while(1) +{ + scanf("%s",dumi); + int lenght = strlen(dumi); + if(dumi[0] == 'S' && dumi[1] == 'T' && dumi[2] == 'O' && dumi[3] == 'P' && dumi[4] == '\0') + { + break; + } + int i; + for(i=0; i= 'a' && dumi[i] <= 'z') + { + dumi[i] -= 32; + } + } + + printf("%s",dumi); +} + + + +return 0; +} diff --git a/2015-2016/V/10/02/task3.c b/2015-2016/V/10/02/task3.c new file mode 100644 index 00000000..a79b2c9f --- /dev/null +++ b/2015-2016/V/10/02/task3.c @@ -0,0 +1,34 @@ +#include +int main() +{ + int array[1000]; + int i=0; + for(; i <1000; i++) + { + scanf("%d",&array[i]); + if(array[i] == 42) + { + break; + } + } + int lenght = i; + for(i=0;i array[j+1]) + { + int b=array[j]; + array[j]=array[j+1]; + array[j+1]=b; + } + } + } + for(i=0;i +#include + +int main(void){ + + bool number[10] = { false }; + int digit; + long n; + + + scanf("%ld", &n); + + printf("povtarqshti se chisla(s):"); + + while (n > 0) + { + digit = n % 10; + if (number[digit] == true) + { + printf("%d ", digit); + } + number[digit] = true; + n /= 10; + } + + return 0; +} diff --git a/2015-2016/V/10/03/task1.c b/2015-2016/V/10/03/task1.c new file mode 100644 index 00000000..38d6237b --- /dev/null +++ b/2015-2016/V/10/03/task1.c @@ -0,0 +1,23 @@ +#include +#include + +int main() +{ + int a,b,i; + scanf("%d",&a); + + for(i=1;i<=a;i++) + { + for(b=1;b<=(2*i-1);b++) + { + printf("*"); + } + + printf("\n"); + } + + + return 0; + +} + diff --git a/2015-2016/V/10/03/task2.c b/2015-2016/V/10/03/task2.c new file mode 100644 index 00000000..a964122f --- /dev/null +++ b/2015-2016/V/10/03/task2.c @@ -0,0 +1,27 @@ +#include +int main() +{ + char str[50]; + char *rev; + printf("vuvedi duma: "); + scanf("%s",str); + rev = strrev(str); + + printf("obyrnatata dyma e: %s",rev); + + return 0; +} +char *strrev(char *str) +{ + char *p1, *p2; + + if (! str || ! *str) + return str; + for (p1 = str, p2 = str + strlen(str) - 1; p2 > p1; ++p1, --p2) + { + *p1 ^= *p2; + *p2 ^= *p1; + *p1 ^= *p2; + } + return str; +} diff --git a/2015-2016/V/10/03/task3.c b/2015-2016/V/10/03/task3.c new file mode 100644 index 00000000..858707c8 --- /dev/null +++ b/2015-2016/V/10/03/task3.c @@ -0,0 +1,42 @@ +#include +#include + +int main() +{ + char m; + char k[13]; + char k2[13] = {'A','K','Q','J','T','9','8','7','6','5','4','3','2'}; + + int i,j; + + do + { + + scanf("%s",k); + }while(strlen(k)!=13); + + + do{ + + + for(i=0;i<=12;i++) + { + for(j=0;j<=12;j++) + { + if(k2[j]==k[i]) + { + m=k[j]; + k[j]=k[i]; + k[i]=m; + break; + } + } + } + }while(strcmp(k2,k) != 0); + + printf("%s",k); + return 0; + +} + + diff --git a/2015-2016/V/10/04/task1.c b/2015-2016/V/10/04/task1.c new file mode 100644 index 00000000..8aa68b09 --- /dev/null +++ b/2015-2016/V/10/04/task1.c @@ -0,0 +1,27 @@ +#include +#include + +int main(void){ + + bool number[10] = { false }; + int digit; + long n; + + //printf("Enter a number: "); + scanf("%ld", &n); + + //printf("Repeated digit(s): "); + + while (n > 0) + { + digit = n % 10; + if (number[digit] == true) + { + printf("%d ", digit); + } + number[digit] = true; + n /= 10; + } + + return 0; +} diff --git a/2015-2016/V/10/04/task2.c b/2015-2016/V/10/04/task2.c new file mode 100644 index 00000000..dc9b7f2d --- /dev/null +++ b/2015-2016/V/10/04/task2.c @@ -0,0 +1,68 @@ +#include + + +int main() { + int size = 3; + int matrix[3][3]; // = {{4,9,2},{3,5,7},{8,1,6}}; + int row, column = 0; + int sum, sum1, sum2; + int flag = 0; + + scanf("vuvedete chislata:"); + for (row = 0; row < size; row++) { + for (column = 0; column < size; column++) + scanf("%d", &matrix[row][column]); + } + + + for (row = 0; row < size; row++) { + printf("\n"); + for (column = 0; column < size; column++) { + printf("\t%d", matrix[row][column]); + } + } + + + sum = 0; + for (row = 0; row < size; row++) { + for (column = 0; column < size; column++) { + if (row == column) + sum = sum + matrix[row][column]; + } + } + + + for (row = 0; row < size; row++) { + sum1 = 0; + for (column = 0; column < size; column++) { + sum1 = sum1 + matrix[row][column]; + } + if (sum == sum1) + flag = 1; + else { + flag = 0; + break; + } + } + + + for (row = 0; row < size; row++) { + sum2 = 0; + for (column = 0; column < size; column++) { + sum2 = sum2 + matrix[column][row]; + } + if (sum == sum2) + flag = 1; + else { + flag = 0; + break; + } + } + + if (flag == 1) + printf("\nmagicheski kvadrat"); + else + printf("\nne e magicheski kvadrat"); + + return 0; +} diff --git a/2015-2016/V/10/05/Untitled Document~ b/2015-2016/V/10/05/Untitled Document~ new file mode 100644 index 00000000..e69de29b diff --git a/2015-2016/V/10/05/task1.c b/2015-2016/V/10/05/task1.c new file mode 100644 index 00000000..d47eaeb5 --- /dev/null +++ b/2015-2016/V/10/05/task1.c @@ -0,0 +1,28 @@ +#include + +int main() +{ + int m=4, n=4, c, d, matrix[10][10], transpose[10][10]; + + + //printf("vuvedi elementite na matricata\n"); + + for (c = 0; c < m; c++) + for(d = 0; d < n; d++) + scanf("%d",&matrix[c][d]); + + for (c = 0; c < m; c++) + for( d = 0 ; d < n ; d++ ) + transpose[d][c] = matrix[c][d]; + + //printf("Transponiraneto na matricata \n"); + + for (c = 0; c < n; c++) { + for (d = 0; d < m; d++) + printf("%d\t",transpose[c][d]); + printf("\n"); + } + + return 0; +} + diff --git a/2015-2016/V/10/05/task2.c b/2015-2016/V/10/05/task2.c new file mode 100644 index 00000000..c207b904 --- /dev/null +++ b/2015-2016/V/10/05/task2.c @@ -0,0 +1,18 @@ +#include +#include +int main(void) +{ + char s[100], b[100]; + + //printf("napishete bukvi za da se proveri dali nizut s e palindrom\n"); + gets(s); + + strcpy(b,s); + strrev(b); + + if (strcmp(s,b) == 0) + printf(" 1\n"); + else + printf(" 0\n"); + return 0; +} diff --git a/2015-2016/V/10/06/Untitled Document~ b/2015-2016/V/10/06/Untitled Document~ new file mode 100644 index 00000000..e69de29b diff --git a/2015-2016/V/10/06/task2.c b/2015-2016/V/10/06/task2.c new file mode 100644 index 00000000..8cfc357a --- /dev/null +++ b/2015-2016/V/10/06/task2.c @@ -0,0 +1,24 @@ +# include +# include + +int isExactSquare(float); + +int main() +{ + int n ; + + //printf("Enter a number : ") ; + scanf("%d", &n) ; + printf("%d",isExactSquare(n)) ; + return 0 ; +} + +int isExactSquare(float p) { + float m = sqrt(p) ; + + if(m == (int)sqrt(p)) + return 1 ; + else + return 0 ; +} + diff --git a/2015-2016/V/10/07/task1.c b/2015-2016/V/10/07/task1.c new file mode 100644 index 00000000..ec797620 --- /dev/null +++ b/2015-2016/V/10/07/task1.c @@ -0,0 +1,26 @@ +#include + + +void rotr(int *a,int *b,int *c) +{ + int n=*a; + *a=*c; + *c=*b; + *b=n; +} +int main() +{ + int a,b,c,t; + int i=0; + scanf("%d",&a); + scanf("%d",&b); + scanf("%d",&c); + scanf("%d",&t); + do{ + rotr(&a,&b,&c); + i++; + }while(i +#include + + void next_generation(int *current,int *next,int lenght); + void print_generation(int *current,int lenght); + int check_generation(int *current,int lenght); + +int main() +{ + int n,i; + int j; + int n1[n]; + + + do{ + + scanf("%d",&n); + }while(n>20 || n <0); + + int c1[n]; + for(i=0;i +#include +#include +#include + +int DECTOHEX(long int jem); +int pow_(int num,int exp); +void HEXTODEC(char *str); +int main() +{ + + + int RGB1,RGB2,RGB3; + char t,str[6]; + do { + scanf("%s",&t); + }while(t!='h' && t != 'd'); + + + +if(t=='d'){ + scanf("%d, %d, %d",&RGB1,&RGB2,&RGB3); + + printf("#%x%x%x",RGB1,RGB2,RGB3); +} +else +{ + + scanf("%*c#%s",str); + + HEXTODEC(str); + RGB1=(str[0]*16)+str[1]; + RGB2=(str[2]*16)+str[3]; + RGB3=(str[4]*16)+str[5]; + + + printf("rgb(%d, %d, %d)",RGB1,RGB2,RGB3); +} + + + + return 0; +} + +void HEXTODEC(char* str) +{ + for(int i = 0;i<6;i++){ + switch(str[i]){ + case 'a':str[i] = 10;break; + case 'b':str[i] = 11;break; + case 'c':str[i] = 12;break; + case 'd':str[i] = 13;break; + case 'e':str[i] = 14;break; + case 'f':str[i] = 15;break; + default: str[i] -= 48; break; + } + } +} + + + diff --git a/2015-2016/V/10/08/task2.c b/2015-2016/V/10/08/task2.c new file mode 100644 index 00000000..73af2230 --- /dev/null +++ b/2015-2016/V/10/08/task2.c @@ -0,0 +1,24 @@ +#include +#include + +int main() +{ + int i,click=0; + char text[160]; + scanf("%[^\n]", text); + for(i=0; i<=strlen(text); i++){ + switch(text[i]){ + case 'a': case 'd': case 'g': case 'j': case 'm': case 'p': case 't': case 'w': case ' ':click++;break; + case 'b': case 'e': case 'h': case 'k': case 'n': case 'q': case 'u': case 'x': click+=2;break; + case 'c': case 'f': case 'i': case 'l': case 'o': case 'r': case 'v': case 'y': click+=3;break; + case 's': case 'z':click+=4;break; + + + + + } + + } + printf("%d",click); + return 0; +} diff --git a/2015-2016/V/10/08/task3.c b/2015-2016/V/10/08/task3.c new file mode 100644 index 00000000..7c7de72c --- /dev/null +++ b/2015-2016/V/10/08/task3.c @@ -0,0 +1,67 @@ +#include +#include +#include + + + +int main() +{ + + int n; //broi na eleni + int i; //broqch + int j,m; + int rudolf; + + + + + //vuvejdane na broq na eleni + + do{ + + scanf("%d",&n); + } + + while(n%2==0 || n<=0 ||n>199); + + //vuvejdane na nomerata na eleni + + int e[n-1]; + for(i=0;i100); + + + } + // tursene na rudolf + + for(i=0;i +int main() +{ + int a,b; + + do + { + scanf("%d",&a); + scanf("%d",&b); + } + while((a<0 || a>7)&(b<0 || b>200)); + + int mask = 1 << a; + int result = b & mask; + if(result==0) + { + printf("0"); + }else printf("1"); + + + + return 0; +} diff --git a/2015-2016/V/10/09/task2.c b/2015-2016/V/10/09/task2.c new file mode 100644 index 00000000..a565b650 --- /dev/null +++ b/2015-2016/V/10/09/task2.c @@ -0,0 +1,30 @@ +#include +int main() +{ + int p,n,v; + + do{ + scanf("%d",&n); + scanf("%d",&v); + scanf("%d",&p); + + }while((v<0 || v>1) || (p<0 || p>7)); + + int mask=1; + //printf("\n%d", mask); + mask=mask << p; + //printf("\n%d", mask); + if(v==0) + { + mask=~mask; + //printf("%d",mask); + n=n&mask; + } + else + { + n=n|mask; + } + printf("%d",n); + +return 0; +} diff --git a/2015-2016/V/10/09/task3.c b/2015-2016/V/10/09/task3.c new file mode 100644 index 00000000..9f376368 --- /dev/null +++ b/2015-2016/V/10/09/task3.c @@ -0,0 +1,79 @@ +#include +#include +#include +#include +#include + +int main() +{ + + int n; + int i=0,j; + char h[4]; + + scanf("%d",&n); + + + sprintf(h,"%x",n); + + int r=strlen(h); + + for (i=0;i=0;i--,j++) + + b[j]=h[i]; + b[j]='\0'; + + + + if(strcmp(b,h) != 0) + + + { + + char s1[r]; + char s2[r]; + + do { + + sprintf(s1,"%d",n); + + r=strlen(s1); + + for (i=r-1,j=0;i>=0;i--,j++) + + s2[j]=s1[i]; + s2[j]='\0'; + + n=n+1; + + }while(strcmp(s1,s2) != 0); + + printf("\n%d",n-1); + + + } + else + printf("%s",h); + + return 0; +} + + + + + + + + + + + +