拜托,请帮我解决这个严重的问题...... [英] Please guyz, kindly help me on this serious problem of mine...

查看:58
本文介绍了拜托,请帮我解决这个严重的问题......的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请别人,请帮我解决我的这个严重问题.......我想将这个变量的答案返回到我的define数组中,以便遍历每一个但是我没有得到它是正确的......



 a4 =( int )(( a / a3)*  70  + a2); 
b4 =( int )((b / b3)* 70 + b2);

int [] many = { 0 0 };
很多[ 0 ] = a4;
很多[ 1 ] = b4;

#region
for int counter = 0 ; counter < 很多。长度;计数器++)
{
if (counter > = 70
{
print = A ;
}
else if (counter > = 60
{
print = B;
}
else if (counter > = 50
{
print = C;
}
else if (gradeCounter > = 40
{
print = D;
}
其他
{
print = F;
}
}





我的尝试:



  //   int [] many = {0,0};  
// many [0] = a4;
// many [1] = b4;
// #region


// for(int counter = 0; counter< many.Length; counter ++)
// {
// if(counter> = 70)
// {
// print =A;
// < span class =code-comment>}
// 否则if(counter> = 60)
// {
// print =B;
// }
// 否则if( counter> = 50)
// {
< span class =code-comment> // print =C;
/ / }
// 否则if(gradeCounter> = 40)
// {
// print =D;
// }
// else
// {
// print =F;
// }
// }

解决方案

您应该学习尽快使用调试器。而不是猜测你的代码在做什么,现在是时候看到你的代码执行并确保它完成你期望的。



调试器允许你跟踪执行逐行检查变量,你会看到它有一个停止做你期望的点。

调试器 - 维基百科,免费的百科全书 [ ^ ]

掌握Visual Studio 2010中的调试 - A初学者指南 [ ^ ]



您的代码看起来有些错误,但由于它不是一段自主的代码,因此无法确定。

使用完整版更新您的问题te功能

使用改善问题更新你的问题。


我怀疑这里



Quote:

for(int counter = 0;计数器< many.Length;计数器++)

{

if(counter> = 70)

{

print =A;

}

else if(counter> = 60)

{

print =B;

}

否则if(counter> = 50)

{

print =C;

}

否则if(gradeCounter> = 40)

{

print =D;

}

其他

{

print =F;

}

}

你真正要做的就是在循环中评估你的'many'数组..所以为什么不呢?



  for  int  counter =  0 ; counter <  many.Length; counter ++)
{
if 许多[柜台] > = 70
{
print = A;
}
其他 如果多[柜台] > = 60
{
print = B;
}
其他 如果多[柜台] > = 50
{
print = C;
}
其他 如果多[柜台] > = 40
{
print = D;
}
其他
{
print = F;
}
}





如果那不是您想要的,那么您必须这样做已被建议,提高问题的质量


  //  避免多个'if''然后''else'实例更清晰 
int [] scores = { 38 40 45 50 56 60 65 70 75 };
int [] gradeLevels = { 70 60 50 40 };
char [] grades = {' A '' B'' C'' D'' F'};
foreach var 得分 分数)
{
int i;
for (i = 0 ; i < ; gradeLevels.Length; i ++)
{
if (得分> = gradeLevels [i])
{
break ;
}
}
Console.WriteLine( 您的分数为{0}。你的成绩是{1},得分,成绩[i]);
}
Console.ReadLine();


please guyz, kindly help me on this serious problem of mine.......i want to return the answer of this variable into my define array in order to iterate through each of them but it i didn't get it right...

a4 = (int)((a / a3) * 70 + a2);
b4 = (int)((b / b3) * 70 + b2);

int[] many = { 0, 0 };
many[0] = a4;
many[1] = b4;

#region
for (int counter = 0; counter < many.Length; counter++)
{
    if (counter >= 70)
    {
        print = "A";
    }
    else if (counter >= 60)
    {
        print = "B";
    }
    else if (counter >= 50)
    {
        print = "C";
    }
    else if (gradeCounter >= 40)
    {
        print = "D";
    }
    else
    {
        print = "F";
    }
}



What I have tried:

//int[] many = { 0, 0 };
            //many[0] = a4;
            //many[1] = b4;
            //#region
          

            //for (int counter = 0; counter < many.Length; counter++)
            //{
            //    if (counter >= 70)
            //    {
            //        print = "A";
            //    }
            //    else if (counter >= 60)
            //    {
            //        print = "B";
            //    }
            //    else if (counter >= 50)
            //    {
            //        print = "C";
            //    }
            //    else if (gradeCounter >= 40)
            //    {
            //        print = "D";
            //    }
            //    else
            //    {
            //        print = "F";
            //    }
            //}

解决方案

You should learn to use the debugger as soon as possible. Rather than guessing what your code is doing, It is time to see your code executing and ensuring that it does what you expect.

The debugger allow you to follow the execution line by line, inspect variables and you will see that there is a point where it stop doing what you expect.
Debugger - Wikipedia, the free encyclopedia[^]
Mastering Debugging in Visual Studio 2010 - A Beginner's Guide[^]

Your code look buggy, but since it is not an autonomous piece of code, it is not possible to tell for sure.
Update your question with the complete function
Use Improve question to update your question.


I suspect here

Quote:

for (int counter = 0; counter < many.Length; counter++)
{
if (counter >= 70)
{
print = "A";
}
else if (counter >= 60)
{
print = "B";
}
else if (counter >= 50)
{
print = "C";
}
else if (gradeCounter >= 40)
{
print = "D";
}
else
{
print = "F";
}
}

what you actually mean to do is evaluate your 'many' array in the loop.. so why not this

for (int counter = 0; counter < many.Length; counter++)
{
    if (many[counter] >= 70)
    {
        print = "A";
    }
    else if (many[counter] >= 60)
    {
        print = "B";
    }
    else if (many[counter] >= 50)
    {
        print = "C";
    }
    else if (many[counter] >= 40)
    {
        print = "D";
    }
    else
    {
        print = "F";
    }
}



If thats not what you're looking for, you'll have to do as has been suggested, improve the quality of your question


//It's cleaner to avoid having multiple instances of 'if' 'then' 'else'
 int[] scores = { 38,40,45,50,56,60,65,70,75};
 int[] gradeLevels = { 70, 60, 50, 40 };
 char[] grades = { 'A', 'B', 'C', 'D', 'F' };
 foreach (var score in scores)
    {
      int i;
      for ( i = 0; i < gradeLevels.Length; i++)
          {
            if (score >= gradeLevels[i])
               {
                break;
               }
          }
      Console.WriteLine("Your score was {0}. Your grade  is {1}",score,grades[i]);
    }
    Console.ReadLine();


这篇关于拜托,请帮我解决这个严重的问题......的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆