GIẢI PHƯƠNG TRÌNH bậc HAI ỨNG DỤNG NGÔN NGỮ c - Pdf 24

GIẢI PHƯƠNG TRÌNH BẬC HAI ỨNG DỤNG NGÔN NGỮ C
#include <stdio.h>
#include <math.h>
void main()
{
float a, b, c, delta;
printf("\nGiai phuong trinh bac hai AXý + BX + C = 0");
printf("\nCho biet ba he so A B C : ");
scanf("%f%f%f", &a, &b, &c);
delta = b * b - 4 * a * c;
if (delta<0)
printf("Phuong trinh vo nghiem");
else if (delta == 0)
printf("Phuong trinh co nghiem kep x1 = x2 = %f", -b/
(2*a));
else
{
printf("Phuong trinh co hai nghiem phan biet\nx1 = %f",
(-b + sqrt(delta))/(2*a));
printf("\nx2 = %f", (-b - sqrt(delta))/(2*a));
}
getch();
}
MA PHƯƠNG
#include <stdio.h>
#include <conio.h>
// func declaration
void matrix( int n );
// main()
int main(void)
{


// set starting value of array
for ( i = 0 ; i < n ; i++ )
for ( j = 0 ; j < n ; j++ )
a[i][j] = 0;

// set the 1st value to start
row = 0; col = (n-1) / 2;

while ( count < n*n + 1 )
{
a[row][col] = count++ ; // set value for
elements
old_row = row ; old_col = col; // save the
last addresses
// define whether going out of array
row -= 1; if ( row == -1 ) row = n - 1;
col += 1; if ( col == n ) col = 0;
// in case of already having number
if ( a[row][col] != 0 )
{
row = old_row + 1;
col = old_col;
} // end if
} // end while
// print result
printf("\n");
for ( i = 0 ; i < n ; i++ )
{
for ( j = 0 ; j < n ; j++ )


Nhờ tải bản gốc

Tài liệu, ebook tham khảo khác

Music ♫

Copyright: Tài liệu đại học © DMCA.com Protection Status