求任意底数和任意真数的对数

来源:互联网 发布:淘宝墙纸大卖场 编辑:程序博客网 时间:2024/04/28 08:13
#include<stdio.h>#include<math.h>int loga(int r,int b);int main(void){  int r,b,l;  printf("What's the base?\n");  scanf("%d",&b);  printf("What's the real number?\n");  scanf("%d",&r);  l=loga(r,b);  printf("The logarithn is %d.\n",l);  return 0;}int loga(int r,int b){  int s=0,i;  for(i=0;s!=r;i++)    s=pow(b,i);  return --i;}

0 0
原创粉丝点击