#include <iostream.h>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <process.h>
#include <string.h>
int main()
{
char stt[8][4] = {NULL, '7','8','9',
'0', '1', NULL, NULL,
'1', '2', '4', NULL,
'2', '3', '3', '3',
'3', NULL, NULL, '3',
'4', '4', '5', '4',
'5', '6', '5', '4',
'6', NULL, NULL, NULL};
char ch, state = '0';
char variable[40];
int flag=0;
cout<<"Input c Comment line : ";
cin>>variable;
for(int i=0; i<40 && variable[i] != NULL; i++)
{
if(variable[i] == '/')
{
ch = '7';
flag=flag+1;
}
elseif(variable[i] == '*')
{
ch ='8';
}
else
{
ch ='9';
}
for(int j=1; stt[0][j] != ch; j++);
for(int k=1; stt[k][0] != state; k++);
state = stt[k][j];
if (state == NULL)
{
printf("Invalide comment line");
getchar();
exit(0);
}
}
if (flag == 1)
{
printf("Invalide comment line");
getchar();
exit(0);
}
else
{
printf("Valide Comment line");
}
getchar();
return 0;
}