使用C,C ++制作程序 [英] make a program using C,C++

查看:60
本文介绍了使用C,C ++制作程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我需要帮助我的项目....如何制作程序

接受任何整数并将其转换为二进制,八进制和十六进制.pls

帮我...谢谢

解决方案



" mavic" <毫安********** @ yahoo.com> schreef在bericht

新闻:11 ********************** @ g14g2000cwa.googlegr oups.com ...

大家好,我需要帮助我的项目....如何制作一个程序
接受任何整数并将其转换为二进制,八进制和十六进制。请帮助我......谢谢




二进制/八进制/十六进制表示会发生什么?


Arne


应该有这些的输出...


这是我的朋友navjot转换十进制系统的程序

整数到二进制。


u可以轻松更改此程序以显示八进制或十六进制或任何其他系统。


#include< stdio.h>

#include< math.h>

main()

{

int i,x,t,answer = 0;

int num [15];


clrscr();


printf("输入二进制数的数字r \ n(按两次Enter键输入

,输入完成后输入9):\ n");


for(i = 0; i< 15; i ++)

{

scanf("%d",& num [i]);

if(num [i]!= 0&& num [i]!= 1)

{break;

}

}


i - ;


x = i;


for(t = 0; t< = x; t ++)

{

/ * while(i> = 0)* /

answer + =(pow(2,t)* num [i]);

i - ;

}


printf("%d",answer);


getch();


}

groups.google.com/group/all-at-c


hi to everybody,i need help for my project....how to make a program
that accept any integer and convert it binary,octal and hexadecimal.pls
help me...thanks

解决方案


"mavic" <ma**********@yahoo.com> schreef in bericht
news:11**********************@g14g2000cwa.googlegr oups.com...

hi to everybody,i need help for my project....how to make a program
that accept any integer and convert it binary,octal and hexadecimal.pls
help me...thanks



And what should happen to the binary/octal/hexadecimal representation?

Arne


there should be an output of these...


here is a program my friend navjot made to convert decimal system
integer to binary.

u can easily change this program to show octal or hexadecimal or any
other system.

#include<stdio.h>
#include<math.h>
main()
{
int i,x,t,answer=0;
int num[15];

clrscr();

printf("Enter the digits of the binary number \n(pressing Enter
between 2 digits and enter 9 when finished entering) : \n");

for(i=0;i<15;i++)
{
scanf("%d",&num[i]);
if( num[i]!=0 && num[i]!=1 )
{break;
}
}

i--;

x=i;

for(t=0;t<=x;t++)
{
/* while(i>=0) */
answer+=(pow(2,t)*num[i]);
i--;
}

printf("%d",answer);

getch();

}
groups.google.com/group/all-at-c


这篇关于使用C,C ++制作程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆