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

论坛 期权论坛 脚本     
匿名技术用户   2020-12-28 04:43   33   0
#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 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:7942463
帖子:1588486
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP