English 中文(简体)
逻辑问题或问题如何?
原标题:logic issue or something more?
  • 时间:2011-11-04 17:41:54
  •  标签:
  • c++
  • loops

我的节目模拟一个视频储存。 我的名单上有多份录像。 如果我试图租用一个录像带,名单上第一个录像带已经租用,那么我的节目就无法继续检查其他复印件是否可用(如果黄玉米为0,则有一部电影)。 从名单上找到成员,以便更好地了解描述什么是:

“在座的影像描述”</p

谁能看一看,让我知道他们是否发现一个问题? 感谢任何帮助。

www.un.org/Depts/DGACM/index_spanish.htm 主要

 try
 {
     int index = 0;
     bool found = false;

     while (!found)
     {
         if (strncmp(filmId,filmList.getAt(index).number,6) == 0 && strncmp("0000",filmList.getAt(index).rent_id,5) == 0)//If that film is rented by NO customer
         {
             found = true;//customer can rent it

             strcpy(newItem.number,filmId);//copy filmId into newItem
             filmList.retrieve(newItem);//copy the struct in our orderedList with the same filmId/copy into newItem
             filmList.remove(newItem);//delete the struct with same filmId/copy as newItem from the orderedList
             strcpy(newItem.rent_id,custId);//update info in
             strcpy(newItem.rent_date,rentDate);//           newItem to show
             strcpy(newItem.return_date,dueDate);//                          that it has been rented
             filmList.insert(newItem);//put NewItem into list, effectivily replacing the removed item.

             cout << "Rent confirmed!" << endl;
         }
         else
         {
             if (strncmp(filmId,filmList.getAt(index).number,6) > 0 || strncmp("0000",filmList.getAt(index).rent_id,5) > 0)
             {
                 ++ index;
             }
             else
             {
                 throw string ("Not in list");
             }
         }
     }
 }
 catch (string s)
 {
     cout << "
***Failure*** " << s << endl;
 }

让我知道,该方案的任何其他部分是否需要更多的法典。

最佳回答

在这方面,我对所提供的守则表示最良好的怀疑。

Let s say we are looking up 101001Casablanca, therefore I m assuming filmId = "101001Casablanca". Also, assume the 101001Casablanca is checked out to customer 0001. We are comparing the first 6 characters of filmId to filmList.getAt(index).number, which I m going to assume is at the very least "101001". This passes, but since it is checked out the second condition fails.

在其他情况下,我们首先检查同样的扼杀,从假冒的扼杀中恢复0。 第二个条件也是假的,因为扼杀(0”、“0001”、“5)为-1。 因此,我们走到最后的道路。

如果你只检查扼杀性病的平等,就会记住,它能够返回-1,因此,如果等于或等于0。

问题回答

暂无回答




相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签