Advertisement
iamthehxc

Untitled

Jul 21st, 2014
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. #include <stdio.h>
  2. int main ()
  3. {
  4. char mystrings[8][5] = { {"ABC"},{"DEF"},{"GHI"},{"JKL"},{"MNO"},
  5. {"PQRS"},{"TUV"},{"WXYZ"} };
  6. int i=0,j=0,k=0;
  7. int num;
  8. int leftdigit, middigit, rightdigit;
  9.  
  10. printf("Enter a number (3-digit): ");
  11. scanf("%d", &num);
  12. printf("\n");
  13.  
  14. if (num%10 == 0 || num%10 == 1)
  15. printf("Invalid input! The number should not contain 0 or 1.\n\n");
  16. else if (((num/10)%10 == 0) || ((num/10)%10 == 1))
  17. printf("Invalid input! The number should not contain 0 or 1.\n\n");
  18. else if (((num/100)%10 == 0) || ((num/100)%10 == 1))
  19. printf("Invalid input! The number should not contain 0 or 1.\n\n");
  20. else
  21. {
  22. printf("The combinations are:\n");
  23. leftdigit=num/100-2;
  24. middigit=(num/10)%10-2;
  25. rightdigit=num%10-2;
  26.  
  27. for(i=0;i<=4;i++)
  28. {
  29. printf("%c", mystrings[leftdigit][i]);
  30. for(j=0; j<=4;j++)
  31. {
  32. printf("%c", mystrings[middigit][j]);
  33. for(k=0;k<=4;k++)
  34. printf("%c", mystrings[rightdigit][k]);
  35. }
  36. printf(", ");
  37. }
  38. }
  39.  
  40. system("PAUSE");
  41. return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement