kiểm tra có nhập đúng MSSV theo form hay không ?

PHOTO EMBED

Thu Aug 19 2021 03:33:17 GMT+0000 (Coordinated Universal Time)

Saved by @_Ryan_ #c

#include<stdio.h>
#include<stdbool.h>
#include<conio.h>
#include<math.h>
#include<string.h>

void main()
{
   int temp, i, j;
   temp = 0;
   char chars[20];

    printf("enter chars : ");
    gets(chars);

    if(chars[0] != 'G')
    {
        temp = 1;

    }
    else if (chars[1] != 'C')
    {
        temp = 1;

    }
    else
    {
        for (i = 2; i < strlen(chars);i++)
        {

            if(isdigit(chars[i]) == 0)
                {
                    temp = 1;
                }
                break;
        }
    }

     if ( temp == 0)
     {
         printf("student ID: ");
         puts(chars);
     }
     else
     {
        printf("enter error");
     }

    getch();

}
content_copyCOPY