Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- int main(){
- int testcases, n1=0, n2, i, k, g, from, to, a, b;
- scanf("%d\n",&testcases);
- for(i=0;i<testcases;i++){
- scanf("\n");
- scanf("%d",&n1);
- char n1_array_from[n1];
- char n1_array_to[n1];
- int table1[n1][n1];
- char conversao[n1];
- for(a=0;a<n1;a++){
- conversao[a]='0';
- for(b=0;b<n1;b++)
- table1[a][b]=0;
- }
- //memset(conversao, 0, n1*sizeof(char));
- for(g=0;g<n1;g++){
- scanf("\n");
- scanf("%c %c ",&n1_array_from[g],&n1_array_to[g]);
- from=-1,to=-1;
- for(k=0;k<n1;k++){
- if(n1_array_from[g]==conversao[k]){
- from = k;
- printf("from:%c-%d\n",conversao[k],k);
- }
- if(n1_array_to[g]==conversao[k]){
- to = k;
- }
- }
- if(from==-1){
- k=0;
- while(conversao[k]!='0')
- k++;
- conversao[k]=n1_array_from[g];
- from = k;
- }
- if(to==-1){
- while(conversao[k]!='0')
- k++;
- conversao[k]=n1_array_to[g];
- to = k;
- }
- table1[from][to] = 1;
- }
- for(a=0;a<n1;a++){
- for(b=0;b<n1;b++){
- printf("%d ",table1[a][b]);
- }
- printf("\n");
- }
- printf("conversao:\n");
- for(a=0;a<n1;a++)
- printf("%c ",conversao[a]);
- /*scanf("%d\n",&n2);
- char n2_array_from[n2];
- char n2_array_to[n2];
- for(g=0;g<n1;g++){
- scanf("%c %c\n",&n2_array_from[g],&n2_array_to[g]);
- }
- int table2[n2][n2] = 0;
- for(i=0;i<n1;i++){
- for(j=0;j<n1;j++){
- if(n1_array_from[i],n1_array_to[i])
- }
- }*/
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement