Advertisement
iamthehxc

Untitled

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