Advertisement
Guest User

Untitled

a guest
May 22nd, 2018
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. int main(){
  6. int testcases, n1=0, n2, i, k, g, from, to, a, b;
  7. scanf("%d\n",&testcases);
  8.  
  9. for(i=0;i<testcases;i++){
  10. scanf("\n");
  11. scanf("%d",&n1);
  12. char n1_array_from[n1];
  13. char n1_array_to[n1];
  14. int table1[n1][n1];
  15. char conversao[n1];
  16. for(a=0;a<n1;a++){
  17. conversao[a]='0';
  18. for(b=0;b<n1;b++)
  19. table1[a][b]=0;
  20. }
  21. //memset(conversao, 0, n1*sizeof(char));
  22. for(g=0;g<n1;g++){
  23. scanf("\n");
  24. scanf("%c %c ",&n1_array_from[g],&n1_array_to[g]);
  25. from=-1,to=-1;
  26. for(k=0;k<n1;k++){
  27. if(n1_array_from[g]==conversao[k]){
  28. from = k;
  29. printf("from:%c-%d\n",conversao[k],k);
  30. }
  31. if(n1_array_to[g]==conversao[k]){
  32. to = k;
  33. }
  34. }
  35. if(from==-1){
  36. k=0;
  37. while(conversao[k]!='0')
  38. k++;
  39. conversao[k]=n1_array_from[g];
  40. from = k;
  41. }
  42. if(to==-1){
  43. while(conversao[k]!='0')
  44. k++;
  45. conversao[k]=n1_array_to[g];
  46. to = k;
  47. }
  48. table1[from][to] = 1;
  49. }
  50.  
  51. for(a=0;a<n1;a++){
  52. for(b=0;b<n1;b++){
  53. printf("%d ",table1[a][b]);
  54. }
  55. printf("\n");
  56. }
  57. printf("conversao:\n");
  58. for(a=0;a<n1;a++)
  59. printf("%c ",conversao[a]);
  60.  
  61. /*scanf("%d\n",&n2);
  62. char n2_array_from[n2];
  63. char n2_array_to[n2];
  64. for(g=0;g<n1;g++){
  65. scanf("%c %c\n",&n2_array_from[g],&n2_array_to[g]);
  66. }
  67.  
  68.  
  69. int table2[n2][n2] = 0;
  70.  
  71. for(i=0;i<n1;i++){
  72. for(j=0;j<n1;j++){
  73. if(n1_array_from[i],n1_array_to[i])
  74. }
  75. }*/
  76. }
  77.  
  78. return 0;
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement