Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <locale.h>
- #include <time.h>
- bintodec(char bin[30])
- {
- int i=0,ch=0,n=0;
- float l=0;
- while (bin[i]){n++;i++;}
- i=0;
- while (bin[i])
- {
- if (bin[i]==49){ch=ch+pow(2,n-1-i);}
- i++;
- }
- printf("%d\n",ch);
- }
- char numtos(int num)
- {
- char ch[20]={'\0'};
- int kl,i=0,n=0;
- kl=num;
- while (kl!=0){kl=kl/10;n++;}
- if (num<0){ch[0]=45;num=num*(-1);}else{i++;}
- while (num>0){
- kl=num%10;
- ch[n-i]=kl+48;
- num=num/10;
- i++;
- }
- printf("%s\n",ch);
- }
- int stonum(char str[30])
- {
- int i=0,l=0;
- while (str[i]){
- l=l*10+(str[i]-48);
- i++;
- }
- printf("%d\n",l);
- return l;
- }
- char stouper(char str[30])
- {
- int i=0;
- while (str[i]){
- if ((str[i]<=122)&&(str[i]>=97)){str[i]-=32;}
- i++;
- }
- return str;
- }
- int main()
- {
- setlocale(LC_CTYPE, "RUSSIAN");
- srand(time(NULL));
- int k=1,l;
- char h[30]={'\0'};
- while (1)
- {
- printf("Введите номер задания, если выход то 0 : ");
- scanf("%d",&k);
- if (k==1){
- printf("Введите строку : ");
- scanf("%s",h);
- stouper(h);
- printf("%s\n",h);
- }
- if (k==2){
- printf("Введите строку : ");
- scanf("%s",h);
- stonum(h);
- }
- if (k==3){
- printf("введите число : ");
- int lol;
- scanf("%d",&lol);
- numtos(lol);
- }
- if (k==4){
- printf("введите двоичную запись : ");
- char h[30]={'\0'};
- scanf("%s",h);
- bintodec(h);
- }
- if (k==0){break;}
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement