• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-cqtcocoa誰得pythonphprubygameguibathyscaphec翻訳計画中(planning stage)omegatframeworktwittertestdomvb.netdirectxbtronarduinopreviewerゲームエンジン

練習用です。いろんなものがごちゃまぜです。


Commit MetaInfo

Revision9e0cdd88f464732172203185bf3e4a4eb83969d3 (tree)
Time2017-03-09 09:43:28
Authorbellyoshi <tccwas@gmai...>
Commiterbellyoshi

Log Message

equal

Change Summary

Incremental Difference

--- a/CPP/ITP1_11/c.cpp
+++ b/CPP/ITP1_11/c.cpp
@@ -27,6 +27,7 @@ public:
2727 int right(void){return values[2];};
2828 int top(void){return values[0];};
2929 int front(void){return values[1];};
30+ bool Equal(dice d);
3031 private:
3132
3233 int indexs[CmdCount][RotateLen];
@@ -103,19 +104,20 @@ void dice::input(void){
103104 values[i] = n;
104105 }
105106 }
107+bool dice::Equal(dice d){
108+ for (int i = 0; i < DICE_SIZE; i++) {
109+ if (d[i] != values[i]){
110+ return false;
111+ }
112+ }
113+ return ture;
114+}
106115 int main(int argc, char const *argv[]) {
107116 dice d1,d2;
108117 d1.input();
109118 d2.input();
110119 d2.setTopAndFront(d1.top(),d1.front());
111- int isEqual = true;
112- for(int i = 0; i < DICE_SIZE; i++){
113- if (d1[i] != d2[i]){
114- isEqual = false;
115- break;
116- }
117- }
118- if (isEqual){
120+ if (d1.Equal(d2)){
119121 cout << "Yes" << endl;
120122 }else{
121123 cout << "No" << endl;