Minimum element of an array
Download 143.95 Kb. Pdf ko'rish
|
MUHAMMAD AL-XORAZMIY NOMIDAGI TOSHKENT AXBOROT TEXNOLOGIYALARI UNIVERSITETI AXBOROT TEXNOLOGIYALARI VA KOMMUNIKATSIYALARINI RIVOJLANTIRISH VAZIRLIGI Bajardi; Rizokulov Abdulaziz Tekshirdi; Begimov O’ktam 1-topshiriq #include #include int main() {//Make an algorithm (flowchart) and a program to determine the minimum element of an array.100 int N=10,min; int A[N]; for(int i=0;i printf("%d ,",A[i]); }puts(""); for(int i=0;i if(A[i]A[i+1]=min; } } printf("Min element:%d ",min); return 0; } 2 topshiriq #include #include int main() { double a, b, c, discriminant, root1, root2, realPart, imagPart; printf("Enter coefficients a, b and c: "); scanf("%lf %lf %lf", &a, &b, &c); discriminant = b * b - 4 * a * c; // condition for real and different roots if (discriminant > 0) { root1 = (-b + sqrt(discriminant)) / (2 * a); root2 = (-b - sqrt(discriminant)) / (2 * a); printf("root1 = %.2lf and root2 = %.2lf", root1, root2); } // condition for real and equal roots else if (discriminant == 0) { root1 = root2 = -b / (2 * a); printf("root1 = root2 = %.2lf;", root1); } // if roots are not real else { realPart = -b / (2 * a); imagPart = sqrt(-discriminant) / (2 * a); printf("root1 = %.2lf+%.2lfi and root2 = %.2f-%.2fi", realPart, imagPart, realPart, imagPart); } } 3-topshiriq #include #include int main(){ int n,m,a,b; printf("A[][] Satrlar sonini kirit"); scanf("%d",&n); printf("A[][] Ustunlar sonini kiriting"); scanf("%d",&m); int A=(int)calloc(n,sizeof(int)); for(int i=0;i for(int j=0;j scanf("%d",&A[i][j]); } } printf("B[][] Satrlar sonini kirit"); scanf("%d",&a); printf("B[][] Ustunlar sonini kiriting"); scanf("%d",&b); int B=(int)calloc(a,sizeof(int)); for(int i=0;iB[i]=(int*)calloc(b,sizeof(int)); for(int j=0;jprintf("B[%d][%d] ",i+1,j+1); scanf("%d",&B[i][j]); } } printf("\nYechish (A+B)*A-B*(2*A+3*B"); for(int i=0;i } puts(""); } for(int i=0;i } free(A); } 4-topshiriq class GFG { static float y(float x) { return (float) Math.sqrt(0.6*x+1.5); } static float z(float x) { return (float) (2*x + Math.sqrt(Math.pow(x,2)+3)); } static float trapezoidal(float a, float b, float n) { float h = (b - a) / n; float s = y(a) / z(b); for (int i = 1; i < n; i++) s += y(a + i * h) / z(a + i * h); return h * s; } public static void main(String[] args) { float x0 = 1.2f; float xn = 3f; int n = 10; System.out.println("Value of integral is " + Math.round(trapezoidal(x0, xn, n) * 10000.0) / 10000.0); } } 5- topshiriq public class Task5 { static final double EPSILON = 0.002; static double func(double x) { return Math.pow(3,x)+2*x-2; } static double derivFunc(double x) { return Math.pow(3,x)*Math.log(3)+2; } static void newtonRaphson(double x) { double h = func(x) / derivFunc(x); while (Math.abs(h) >= EPSILON) { h = func(x) / derivFunc(x); x = x - h; } System.out.print("The value of the" + " root is : " + Math.round(x * 100.0) / 100.0); } public static void main(String[] args) { double x0 = 1; newtonRaphson(x0); } } 6-topshiriq public class Task5 { static final double EPSILON = 0.002; static double func(double x) { return Math.pow(x,3)+0.1*Math.pow(x,2)+0.4*x+1.5; } static double derivFunc(double x) { return 3*Math.pow(x,2)+0.2*x+0.4; } static void newtonRaphson(double x) { double h = func(x) / derivFunc(x); while (Math.abs(h) >= EPSILON) { h = func(x) / derivFunc(x); x = x - h; } System.out.print("The value of the" + " root is : " + Math.round(x * 100.0) / 100.0); } public static void main(String[] args) { double x0 = 1; newtonRaphson(x0); } } Download 143.95 Kb. Do'stlaringiz bilan baham: |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling