Jump to content

[C] Ajuda: Problemas com o código II


Recommended Posts

Posted
    #include <stdio.h>
    #include <stdlib.h>
    #include <conio.h>
   #include <string.h>

    main()
    {
      FILE *fp; /*fp- is a file pointer*/
      char componente[10],referencia[10];
      int no1,no2,valor1,valor2;

      /* open the file netlist.txt to read */
      fp = fopen( "netlist1.txt", "r" );
      if (fscanf(fp,"%s",&componente))
	  (componente[0]=='/');
	  printf("comment found");

  while
		(fscanf( fp,"\n%s %s %d %d %d %d\n",&componente,&referencia,&no1,&no2,&valor1,&valor2)!=EOF)
		printf("\n%s %s %d %d %d %d\n",componente,referencia,no1,no2,valor1,valor2);
      

  
  /* close file */
      fclose( fp );
    }

o programa tem por objectivo ler de um ficheiro os nos e dp introduzir um valor numa matriz..

componente|referencia |  no1 | no2 |valor1 | valor2

UR              |  s              |1      |0      |15      |1000          <----- este é o ficheiro de onde vai ler...

R                |  a              | 1      |2      |2200  |  0

R                |  b              | 1      |3      |1500  |0

R                |  c              | 2      |3      |4700  |0

R                |  d              | 2      |0      |560    |0

R                |  e              |3      |0      |3300  |0

tinha de imprimir uma coisa do tipo

matriz[no1][no1]=+1/valor2

matriz[no2][no2]=+1/valor2

matriz[no1][no2]=-1/valor2

matriz[no2][no1]=-1/valor2

se alguem me puder ajudar!!!

Posted

Não percebi qual é a dúvida...  😉

Sim, tens de ser mais explícito.

tenta dizer como queres os dados e como te estão a aparecer.

"Nunca discutas com um idiota. Eles arrastam-te até ao seu nível e depois ganham-te em experiência"

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.