支配值数目问题,看看吧
程序代码:
#include< stdio.h > #include< stdlib.h > int main( void ) { int f[] = {1,3,5,7,9}; int g[] = {2,3,4,7,8}; int k; int t( int f[],int g[],int m,int n ) m = sizeof(f[]); n = sizeof(g[]); k = t( f[],g[],m,n ); printf( "%d",k); system( "pause" ); } int t( int f[], int g[], int m,int n ) { int a, b, count; count = a = b = 0; while( a < m && b < n ) { if( f[a] <= g[b] ) a++; else b++, count += m - a; return count } } 运行不了, 我改成下面的来是一样 #include< stdio.h > #include< stdlib.h > int main( void ) { int f[] = {1,3,5,7,9}; int g[] = {2,3,4,7,8}; int k; int m = 5; int n = 5; int t( int f[],int g[],int m,int n ) k = t( f[],g[],m,n ); printf( "%d",k); system( "pause" ); } int t( int f[], int g[], int m,int n ) { int a, b, count; count = a = b = 0; while( a < m && b < n ) { if( f[a] <= g[b] ) a++; else b++, count += m - a; return count } }