Advertisement
erfanul007

LA 5047 wrong answer

Nov 30th, 2018
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<string.h>
  3.  
  4. int main()
  5. {
  6. char a[20], b[20];
  7. int n,i;
  8. scanf("%d",&n);
  9. for(i=1;i<=n;i++){
  10. scanf("%s %s",a,b);
  11. int lena,lenb,j,k=0,cnt=0,cn=0,num=0;
  12. lena=strlen(a);
  13. lenb=strlen(b);
  14.  
  15. if(lena<lenb)
  16. printf("Case %d: Wrong password.\n",i);
  17.  
  18. else if(lena==lenb){
  19. for(j=0;j<lena;j++){
  20. if(a[j]==b[j])
  21. cnt++;
  22. if(((a[j]-64)==(b[j]-96))||((a[j]-96)==(b[j]-64)))
  23. cn++;
  24. }
  25. if(cnt==lena)
  26. printf("Case %d: Login successful.\n");
  27.  
  28. else if(cn==lena)
  29. printf("Case %d: Wrong password. Please, check your caps lock key.\n",i);
  30.  
  31. else
  32. printf("Case %d: Wrong password.\n",i);
  33. }
  34. else if(lena>lenb){
  35. for(j=0;j<lena;j++){
  36. if((a[j]-48)>=0 && (a[j]-48)<=9){
  37. num++;
  38. cnt++;
  39. cn++;
  40. continue;
  41. }
  42. if(a[j]==b[k])
  43. cnt++;
  44.  
  45. else if(((a[j]-64)==(b[k]-96))||((a[j]-96)==(b[k]-64)))
  46. cn++;
  47.  
  48. k++;
  49. }
  50. if(num>0){
  51. if(cn==lena)
  52. printf("Case %d: Wrong password. Please, check your caps lock and num lock keys.\n",i);
  53.  
  54. else if(cnt==lena)
  55. printf("Case %d: Wrong password. Please, check your num lock key.\n",i);
  56.  
  57. else
  58. printf("Case %d: Wrong password.\n",i);
  59. }
  60. else
  61. printf("Case %d: Wrong password.\n",i);
  62. }
  63. }
  64. return 0;
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement