// 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; }
|