C#编程,5本书3个人拿有多少种方法!

来源:百度知道 编辑:UC知道 时间:2024/05/28 17:17:58
我用哦是for语句,可是总是出错!说是不存在变量和ToString对应我将代码发上来,请懂的人帮帮忙!
int count = 0;

for ( int a = 1; a < 5; a++) ;
{
for ( int b = 1; b < 5; b++) ;
{
for ( int c = 1; c < 5; c++) ;
{

if(a!=b && a!=c && c!=b );
count++;
Console.WriteLine("a"+a.ToString+"b"+b.ToSring+"c"+count.ToString);
Console .WriteLine("count:"+count.ToString);
Console .ReadLine();
这个问题是一个组合问题!5本书 有3个人来拿,有多少种拿的方式!然后我解决了低级错误!程序也算出来了,可是答案却不对!

int count = 0;

for ( int a = 0; a < 5; a++) ;
{
for ( int b = 0; b < 5; b++) ;
{
for ( int c = 0; c < 5; c++) ;
{

if(a!=b && a!=c && c!=b );
count++;
Console.WriteLine("a"+a.ToString+"b"+b.ToSring+"c"+count.ToString);
Console .WriteLine("count:"+count.ToString);
Console .ReadLine();

1.给五本书编号为1,2,3,4,5, 所以,循环应该是1,<=5
2. Console.WriteLine("a"+a.ToString+"b"+b.ToSring+"c"+count.ToString);
中的“count”改为“c”
3. Console.WriteLine("a"+a.ToString+"b"+b.ToSring+"c"+count.ToString);
中的“ToString”改为“ToString()”
4.Console .WriteLine("count:"+count.ToString);
中的“ToString”改为“ToString()”