C++ 도와 주세요!!ㅠ.ㅠ

윤여원2007.06.22
조회74

C++ 고수님들 도와 주싶시오!!

빨간부분~ 주민등록번호 진짜인지 가짜인지 검사하는건데요!!

어떻게 수정하면 될까요!!

그리고 void Insert 에서요!!

별명을 등록할때 같은 별명이 있으면 등록되지 않고 같은 별명이 있다는 경고문을 뜨게 할수 있을까요!!

도와 주세요!!ㅠ.ㅠ

너무 어려워요!! 이코딩 짜는데도 하루 꼬박 걸렸어요!!ㅠ.ㅠ

 

#include <iostream>

using namespace std;

#define nicknameAA 20
#define nameAA 20
#define residentAA 20
#define addressAA 30
#define emailAA 20
#define phoneAA 20
#define Max 100

typedef struct individualAA
{
 char nickname[nicknameAA];
 char name[nameAA];
 char resident[residentAA];
 char address[addressAA];
 char email[emailAA];
 char phone[phoneAA];

}individual;

individual array[Max];  
int index=0;

//메뉴
void Menu()
{
 
 cout<<"MENU----------------"<<endl;
 cout<<"1. 주민등록번호 검사"<<endl;
    cout<<"2. 등    록         "<<endl;
 cout<<"3. 조    회         "<<endl;
 cout<<"4. 전체조회         "<<endl;
 cout<<"5. 수    정         "<<endl;
 cout<<"6. 삭    제         "<<endl;
 cout<<"0. 종    료         "<<endl;
 cout<<"End-----------------"<<endl;


}

//주민번호 검사
int Resident(void)
{
 int check(const char* resNo);
 {
  char buff[16];
  cout << "주민등록번호 13자리를 입력하세요: ";
  cin >> "%13s",buff;
  if(check(buff)) cout << "올바른 번호입니다.";
  else cout << "잘못된 번호입니다.";
  return 0;
 }
 
 int check (const char* strno)
 {
  int i, total=0, checkDigit;
  if(strno[6]<'1' || strno[6]>'3') return 0;
  for(i=0 ;i<12 ;i++){
   if(strno[i]<'0' || strno[i]>'9') return 0;
   total += (i%8+2) * (strno[i]-'0');
  }
  i = 11 - total%11;
  checkDigit = strno[12]-'0';
  if(checkDigit!=i && checkDigit!=i-10) return 0;
  return 1;
 }
}

//등록
void Insert()
{
    char nickname[nicknameAA];
 char name[nameAA];
 char resident[residentAA];
 char address[addressAA];
 char email[emailAA];
 char phone[phoneAA];


 cout << "별 명:";
    cin >> nickname;
 cout << "이 름:";
 cin >> name;
 cout << "주민등록번호:";
    cin >> resident;
 cout << "주 소:";
    cin >> address;
 cout << "이메일:";
    cin >> email;
 cout << "전화번호:";
    cin >> phone;

 strcpy(array[index].nickname, nickname);
 strcpy(array[index].name, name);
 strcpy(array[index].resident, resident);
 strcpy(array[index].address, address);
 strcpy(array[index].email, email);
 strcpy(array[index].phone, phone);
 index++;
 cout << "등록 되었습니다" << endl;

}

//검색
void Search()

{
 int i , count=0;
 char nickname[nicknameAA];
 cout<<"별명을 입력하시오:";
 cin >> nickname;
 for(i=0; i<index; i++)
 {
  if(strcmp(array[i].nickname, nickname)==0)
  {
   cout << "━━━━━━━━━" << endl;
   cout << "별 명:" << array[i].nickname << endl;
   cout << "이 름:" << array[i].name << endl;
   cout << "주민등록번호:" << array[i].resident << endl;
   cout << "주 소:" << array[i].address << endl;
   cout << "이메일:" << array[i].email << endl;
   cout << "전화번호:" << array[i].phone << endl;
   cout << "━━━━━━━━━" << endl;
   count++;
  }
 }
 if(count==0)
   cout << "잘못 눌렀습니다" << endl;
}

//전체검색
void Allsearch()
{
 int i;
 for(i=0; i<index; i++)
 {
  cout << "━━━━━━━━━" << endl;
  cout << "별 명:" << array[i].nickname << endl;
  cout << "이 름:" << array[i].name << endl;
  cout << "주민등록번호:" << array[i].resident << endl;
  cout << "주 소:" << array[i].address << endl;
  cout << "이메일:" << array[i].email << endl;
  cout << "전화번호:" << array[i].phone << endl;
  cout << ""<< endl;
 }
}

//수정
void Revision()
{
 int i=0, z, count=0;

 char nickname[nicknameAA];
 char name[nameAA];
 char resident[residentAA];
 char address[addressAA];
 char email[emailAA];
 char phone[phoneAA];
 
 cout << "수정할 별명을 입력하시오:";
 cin >> nickname;
 
 for(i=0; i<index; i++) 
 {
  if(strcmp(array[i].nickname,nickname)==0)
  {
   cout << "1.별 명" << endl;
   cout << "2.이 름" << endl;
   cout << "3.주민등록번호" << endl;
   cout << "4.주 소" << endl;
   cout << "5.이메일" << endl;
   cout << "6.전화번호" << endl;
   cout << "7.전체수정" << endl;
   cout<<"번호입력:";
   cin>>z;
   
   switch (z)
   {
    case 1:
     cout << "별 명:";
     cin >> nickname;
     strcpy(array[i].nickname, nickname);
     break;
    case 2:
     cout << "이 름:";
     cin >> name;
     strcpy(array[i].name, name);
     break;
    case 3:
     cout << "주민등록번호";
     cin >> resident;
     strcpy(array[i].resident, resident);
     break;
    case 4:
     cout << "주 소:";
     cin >> address;
     strcpy(array[i].address, address);
     break;
    case 5:
     cout << "이메일:";
     cin >> email;
     strcpy(array[i].email, email);
     break;
    case 6:
     cout << "전화번호:";
     cin >> phone;
     strcpy(array[i].phone, phone);
     break;
    case 7:
     cout << "별 명:";
     cin >> nickname;
     strcpy(array[i].nickname, nickname);
     cout << "이 름:";
     cin >> name;
     strcpy(array[i].name, name);
        cout << "주민등록번호";
     cin >> resident;
     strcpy(array[i].resident, resident);
     cout << "주 소:";
     cin >> address;
     strcpy(array[i].address, address);
     cout << "이메일:";
     cin >> email;
     strcpy(array[i].email, email);
        cout << "전화번호:";
     cin >> phone;
     strcpy(array[i].phone, phone);
     break;
    default:
     cout << "잘못 눌렀습니다" << endl;
   }
   cout << "수정 되었습니다" << endl;
   count++;
  }
 }
}

//삭제
void Delete()
{
 int i, j,count=0;
 char nickname[nicknameAA];
  
 cout << "삭제할 별명을 입력하시오:";
 cin >> nickname;
 for(i=0; i<index; i++)
 {
  if(strcmp(array[i].nickname, nickname)==0)
  {
   for(j=i+1; j<index; j++)
   {
    strcpy(array[j-1].nickname, array[j].nickname);
    strcpy(array[j-1].name, array[j].name);
    strcpy(array[j-1].resident, array[j].resident);
    strcpy(array[j-1].address, array[j].address);
    strcpy(array[j-1].email, array[j].email);
    strcpy(array[j-1].phone, array[j].phone);
   }
   cout << "삭제 되었습니다" << endl;
   index--; 
   count++;
  }
 }
 if(count == 0)
  cout << "잘못 눌렀어요" << endl;
}


int main()
{
 int choice;
 while(1)
 {
  system("cls");
  Menu();
  cout << "메뉴를 선택하세요:";
  cin >> choice;
  
  switch(choice)
  {
  case 1 :
   Resident();
   system("pause");
   break;
  case 2 :
   Insert();
   system("pause");
   break;
  case 3 :
   Search();
   system("pause");
   break;
  case 4 :
   Allsearch();
   system("pause");
   break;
  case 5 :
   Revision();
   system("pause");
   break;
  case 6 :
   Delete();  
   system("pause");
   break;
  case 0 :
   return 0;
  default :
   cout<<"잘못 누르셨습니다"<<endl;
   system("pause");
   break;
  }
 }
 return 0;
}