fork download
  1. #include <stdio.h>
  2. #include <ctype.h>
  3. #define COD_ID 7
  4.  
  5. int verificaCodigo(char nome[]){
  6. int i, flag=1;
  7.  
  8. for(i=0;i<COD_ID;i++){
  9. if(i<3){
  10. if(!isalpha(nome[i])){
  11. flag=0;
  12. break;
  13. }
  14. }else{
  15. if(!isdigit(nome[i])){
  16. flag=0;
  17. break;
  18. }
  19. }
  20. }
  21.  
  22. return flag;
  23. }
  24.  
  25. int main(int argc, char *argv[]) {
  26. printf("%d\n", verificaCodigo("ABC1234")); //1
  27. printf("%d\n", verificaCodigo("1BC1234")); //0
  28. printf("%d\n", verificaCodigo("AB11234")); //0
  29. printf("%d\n", verificaCodigo("QQQ9999")); //1
  30. printf("%d\n", verificaCodigo("123ABCD")); //0
  31. printf("%d\n", verificaCodigo("abc1234")); //1
  32. printf("%d\n", verificaCodigo("aBc9999")); //1
  33. printf("%d\n", verificaCodigo("a0b1234")); //0
  34. return 0;
  35. }
  36.  
Success #stdin #stdout 0s 9424KB
stdin
Standard input is empty
stdout
1
0
0
1
0
1
1
0