// TEST2.cpp : Defines the entry point for the console application.
//  http://wmnmtm.blog.163.com/blog/static/38245714201173073922482/

#include "stdafx.h"

 

void x264_reduce_fraction( int *n, int *d )
{
    int a = *n;
    int b = *d;
    int c;
    if( !a || !b ) /* 即a和b中,只要有 0 存在 */
        return;
    c = a % b;
    while(c)
    {
 a = b;
 b = c;
 c = a % b;
    }
    *n /= b; /* 把原值改掉了 */
    *d /= b; /* 把原值改掉了 */
}


int main(int argc, char* argv[])
{

 int a1,b1;
 a1=5;
 b1=25;
 printf("\n\n");

 printf("原值:\n");
 printf("a1=%d\n",a1);
 printf("b1=%d\n\n",b1);

 printf("**********************************************\n");
 x264_reduce_fraction(&a1,&b1);
 printf("调用x264_reduce_fraction(&a1,&b1)\n");
 printf("**********************************************\n");

 printf("\n现值:\n");
 printf("a1=%d\n",a1);
 printf("b1=%d\n",b1);

 return 0;
}

      
2011年08月30日

相关文章:

  • 2022-02-19
  • 2021-10-04
  • 2022-01-24
  • 2022-01-17
  • 2021-12-03
  • 2021-06-23
  • 2021-06-08
  • 2021-09-20
猜你喜欢
  • 2021-06-29
  • 2021-06-03
  • 2021-11-27
  • 2022-01-12
  • 2021-10-10
  • 2021-06-09
  • 2022-01-19
相关资源
相似解决方案