这道题很简单。明显人家是要你总结其规律。
计算线路的公式应该是:(m+1)*n
#include <stdio.h>
int f(int, int);
int main(void)
{
int m = 3;
int n = 2;
int count = 0;
count = f(m - 1,n - 1);
if(0 == count){
printf("无解!\n");
}
else{
printf("共有%d种线路\n", count);
}
return 0;
}
int f(int m, int n)
{
int result = 0;
if(m > 0 && n > 0){
result = (m + 1) * n;
}
return result;
}
计算线路的公式应该是:(m+1)*n
#include <stdio.h>
int f(int, int);
int main(void)
{
int m = 3;
int n = 2;
int count = 0;
count = f(m - 1,n - 1);
if(0 == count){
printf("无解!\n");
}
else{
printf("共有%d种线路\n", count);
}
return 0;
}
int f(int m, int n)
{
int result = 0;
if(m > 0 && n > 0){
result = (m + 1) * n;
}
return result;
}