n natural soni berilgan sonining dastlabki n ta darajasidan tashkil topgan massivni
Download 105.02 Kb. Pdf ko'rish
|
2-variant
2-variant 2. n natural soni berilgan. 2 sonining dastlabki n ta darajasidan tashkil topgan massivni hosil qiling va elementlarini chiqaring. (1, 2, 4, 8, ….) Javob: int n; Console.Write( "n = " ); n = Convert.ToInt32(Console.ReadLine()); double [] massiv = new double [n]; for ( int i = 0, j = 2; i < n; i++) { massiv[i] = Math.Pow(j, i); Console.WriteLine(massiv[i]); } 2. m va n butun musbat sonlari berilgan. m x n o’lchamli matritsani shunday hosil qilingki, uning har bir j – ustuni elementlari 5 * j ga teng bo’lsin. (j =0, 1, …, n - 1) Javob: int m = Convert.ToInt32(Console.ReadLine()); int n = Convert.ToInt32(Console.ReadLine()); double [,] ss = new double [m, n]; for ( int i = 0; i < m; i++) { for ( int j = 0; j < n; j++) { ss[i, j] = Convert.ToDouble(Console.ReadLine()); } } for ( int i = 0; i < m; i++) { for ( int j = 0; j < n; j++) { Console.Write(ss[i, j] + " " ); } Console.WriteLine(); } int a = n * 5; double [,] aa = new double [m, a]; Console.WriteLine(aa[m, a]); 2. Satr berilgan. Satrdagi katta lotin harflari sonini aniqlovchi dastur tuzilsin. Javob: string satr = (Console.ReadLine()); int n = 0; for ( int i = 0; i < satr.Length; i++) { if (satr[i] >= 65 && satr[i] <= 90) { n++; } } Console.WriteLine( "Katta lotin harflari soni: " + n); Download 105.02 Kb. Do'stlaringiz bilan baham: |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling