#25671: 初學者寫法請見諒,用更好寫法歡迎告訴我


jiananlin031@gmail.com (小迪芯)

School : 國立東勢高級工業職業學校
ID : 156261
IP address : [114.41.197.250]
Last Login :
2021-06-11 07:30:54
a020. 身分證檢驗 | From: [114.41.197.250] | Post Date : 2021-06-11 07:11

#include <iostream>

#include <cstdlib>

using namespace std;

int main(int argc, char** argv) {

  string card,one,s1,s2,s3,s4,s5,s6,s7,s8,s9;

  int s0,sum,sum1,sum2,sum3,sum4,sum5,sum6,sum7,sum8,sum9;

  cin >> card;

  one = card[0];

  s1 = card[1]; s2 = card[2]; s3 = card[3]; s4 = card[4]; s5 = card[5]; s6 = card[6]; s7 = card[7]; s8 = card[8]; s9 = card[9];

  sum1 = atoi(s1.c_str()); sum2 = atoi(s2.c_str());sum3 = atoi(s3.c_str());sum4 = atoi(s4.c_str());sum5 = atoi(s5.c_str());sum6 = atoi(s6.c_str());sum7 = atoi(s7.c_str());sum8 = atoi(s8.c_str());sum9 = atoi(s9.c_str());

  sum = sum1 * 8 + sum2 * 7 + sum3 * 6 + sum4 * 5 + sum5 * 4 + sum6 * 3 + sum7 * 2 + sum8 * 1 + sum9;

  if(one == "A"){s0 = (0*9)+1;}

  else if (one == "B"){s0 = (1*9)+1;}

  else if (one == "C"){s0 = (2*9)+1;}

  else if (one == "D"){s0 = (3*9)+1;}

  else if (one == "E"){s0 = (4*9)+1;}

  else if (one == "F"){s0 = (5*9)+1;}

  else if (one == "G"){s0 = (6*9)+1;}

  else if (one == "H"){s0 = (7*9)+1;}

  else if (one == "I"){s0 = (4*9)+3;}

  else if (one == "J"){s0 = (8*9)+1;}

  else if (one == "K"){s0 = (9*9)+1;}

  else if (one == "L"){s0 = (0*9)+2;}

  else if (one == "M"){s0 = (1*9)+2;}

  else if (one == "N"){s0 = (2*9)+2;}

  else if (one == "O"){s0 = (5*9)+3;}

  else if (one == "P"){s0 = (3*9)+2;}

  else if (one == "Q"){s0 = (4*9)+2;}

  else if (one == "R"){s0 = (5*9)+2;}

  else if (one == "S"){s0 = (6*9)+2;}

  else if (one == "T"){s0 = (7*9)+2;}

  else if (one == "U"){s0 = (8*9)+2;}

  else if (one == "V"){s0 = (9*9)+2;}

  else if (one == "W"){s0 = (2*9)+3;}

  else if (one == "X"){s0 = (0*9)+3;}

  else if (one == "Y"){s0 = (1*9)+3;}

  else if (one == "Z"){s0 = (3*9)+3;}

  s0 = s0 / 1 % 10;

  sum = sum / 1 % 10;

  sum = sum + s0;

  if(sum % 10 == 0){

  cout << "real\n";

  }

 else{

  cout << "fake\n";

  }

}

 
ZeroJudge Forum