n个顶点,有(n-1)*n/2条边,每走一次都需要(也只需)n条边才能经过n个顶点,所以最终答案就是(n-1)/2。([(n-1)*n/2]/n)。
#include<iostream>
using namespace std;
int main()
{
int n;
while(cin>>n &&n)
{
cout<<(n-1)/2<<endl;
}
return 0;
}
原文地址:http://blog.csdn.net/a809146548/article/details/44310705