Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- /* run this program using the console pauser or add your own getch, system("pause") or input loop */
- int main() {
- int n;
- printf("digite o numero de equacoes: ");
- scanf("%d", &n);
- int a[n][n], i, j, k, b[4], aux[n], o, s, x=0;
- int m;
- for ( i=0; i<n; i++ ){
- for ( j=0; j<n; j++ )
- {
- printf (" [%d][%d] = ", i, j);
- scanf ("%d", &a[i][j]);
- }
- printf("\n");
- }
- for(k=0;k<n;k++){
- for(i=k+1;i<n;i++){
- while((a[k][k])==0){
- for(o=0;o<n;o++){
- aux[o]=a[o][k];
- }
- for(o=0;o<n;o++){
- a[o][k]=a[o][k+1];
- }
- for(o=0;o<n;o++){
- a[o][k+1]=aux[o];
- }
- }
- m=a[i][k]/a[k][k];
- for(j=k;j<n;j++){
- a[i][j]=a[i][j]-m*a[k][j];
- }
- a[i][k]=0;
- b[i]=b[i]-m*b[k];
- }
- }
- for ( i=0; i<n; i++ ){
- for ( j=0; j<n; j++ )
- {
- printf ("%d ", a[i][j]);
- }
- printf("\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement