Мазмұнға өту
dan_ntu

Данияр Мырзаканов

@dan_ntu

Сайтта 2010 ж. 29 наурызКазахстан, Алматы

Қазақстан халқы үшін қызмет жасаймын

рейтинг

100

жазбалар

173

пікірлер

73

тіркелуші

96

жазылымдар

7

Екі өлшемді А(10,10) жиымда әрбір жол үшін оң элементтердің қосындысын есептеп шығарыңдар.

#include <iostream>
using namespace std;
int main(int argc, char** argv) {
int a[10][10];
int s;
for (int i=0;i<10;i++)
for (int j=0;j<10;j++)
{
cout<<"a["<<i<<"]["<<j<<"]=";
cin>>a[i][j];
}
for (int i=0;i<10;i++){
s=0;
for (int j=0;j<10;j++){
if(a[i][j]>0) s=s+a[i][j];
}
cout<<i+1<<" zholdagi on sandar kosindisi = "<<s<<endl;
}
system("pause");
return 0;
}
-1
0
3322

Кез келген сандардың бір өлшемді А(10)жиымындағы оң элементтерді екі есе кемітіңдер,ал теріс элементтері болсы, онда оларды индекстерінің мәнімен ауыстырыңдар.

#include <iostream>
using namespace std;
int main(int argc, char** argv) {
double a[10];
for (int i=0;i<10;i++){
cout<<"a["<<i<<"]=";
cin>>a[i];
}
for (int i=0;i<10;i++){
if(a[i]>0) a[i]=a[i]/2;
else a[i]=i;
}
cout<<"Онделген массив "<<endl;
for(int i=0;i<10;i++)
cout<<"a["<<i<<"]="<<a[i]<<" ";
system("pause");
return 0;
}
-1
0
3098

1 ден N-ге дейін сандардың қосындысын есептейтін прогрпмма құрыңдар.N-нің мәні пернетақтадан енгізіледі.

#include <iostream>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char** argv) {
int n;
int s=0;
cout<<"Vvedite n = ";
cin>>n;
for(int i=1;i<n;i++)
s=s+i;
cout<<"Summa 1 do "<<n<<" = "<<s<<endl;
system("pause");
return 0;
}
-1
1
5904

Бiрөлшемдi А(10) жиымындағы терiс элементтердiң ең үлкенiн табыңдар.

#include <iostream>
using namespace std;
int main()
{
const int  n=10;
int a[10];
cout<<"Zapolnite massive a"<<endl;
for (int i=0;i<n;i++){
cout<<"a["<<i<<"]=";
cin>>a[i];
}
cout<<"\nmassive a"<<endl;
for (int i=0;i<n;i++){
cout<<"a["<<i<<"]="<<a[i]<<" ";
}
unsigned int i = 0;
while ( i < n && !( a[i] < 0 ) ) i++;
unsigned int max = i;
if ( i < n )
{
for ( i++ ; i < n ; i++ )
{
if ( a[i] < 0 && a[max] < a[i] ) max = i;
}
}
if ( max != n ) std::cout << "\n maximum = " << a[max] << std::endl;
else std::cout << "\n Net otrisatelnix chisel\n";
system("pause");
return 0;
}
0
0
3064

Төрт массив берiлген А(15), В(15),C(15) және D(15). Массивтердiң тақ орындарында тұрған минимал элементердiң қосындысын табу керек. Бiр массивте минимал элемементтi анықтауды функция тұрiнде ұйымдастыру.

import java.util.Random; /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /** * * @author DMyrzaka */ public class Massive { static int minim(int x[]){ int min=x[0]; for (int i=1;i&lt;x.length;i++) { if (i % 2 ==1){ if (x[i]&lt;min) min=x[i]; } } return min; } public static void main(String args[]){ int a[] = new int[15]; int b[] = new int[15]; int c[] = new int[15]; int d[] = new int[15]; for (int i=0;i&lt;a.length;i++) a[i]= new Random().nextInt(100); for (int i=0;i&lt;b.length;i++) b[i]= new Random().nextInt(100); for (int i=0;i&lt;c.length;i++) c[i]= new Random().nextInt(100); for (int i=0;i&lt;d.length;i++) d[i]= new Random().nextInt(100); System.out.pri…

0
0
402

А(10) массив берілген. Ең бірінші нөлдік элементің алдындағы оң таңбалы элементтердің қосындысы мен санын табыңыз.

import java.util.Random;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author DMyrzaka
*/
public class Esep10 {
public static void main(String args[]){
int a[] = new int[10];
int n=10;
int j=0;
int sum=0,k=0;
Random r = new Random();
for (int i=0;i<n;i++)
a[i]=r.nextInt(10);
for(int i=0;i<n;i++)
System.out.print("a["+i+"]="+a[i]+" ");
for(int i=0;i<n;i++)
if (a[i]==0) { j=i; break; }
System.out.println("j="+j);
for (int i=0;i<j;i++){
if (a[i]>0){
sum=sum+a[i];
k++;
}
}
System.out.println("\nЕн биринши нолдик элементтинин он сандардын косындысы " +sum+" жане саны "+k);
}
}
0
0
3075

Мөлшері m*n берілген А матрицасының k-шы бағанасының элементтерін S санына көбейтетін программа жазыңыз.

import java.util.Random;
import java.util.Scanner;
public class Esep5 {
public static void main(String args[]){
int m,n;
int A[][]=new int[100][100];
Scanner sc = new Scanner(System.in);
System.out.println("m->");
m=sc.nextInt();
System.out.println("n->");
n=sc.nextInt();
Random r = new Random();
for(int i=0;i<m;i++)
for(int j=0;j<n;j++)
A[i][j]=r.nextInt(10);
for(int i=0;i<m;i++){
for (int j=0;j<n;j++){
System.out.print(A[i][j]+" ");
}
System.out.println();
}
System.out.println("k->");
int k=sc.nextInt();
System.out.println("S->");
int S=sc.nextInt();
for (int i=0;i<m;i++)
A[i][k]=A[i][k]*S;
for(int i=0;i<m;i++){
for (int j=0;j<n;j++){
System.out.print(A[i][j]+" ");
}
System.out.println();
}
}
}
0
0
734

Нақты Х=(х1, х2, ...., х8) векторының кем дегенде бір теріс компоненті бар екені белгілі. Реті бойынша орналасқан бірінші теріс компоненттің нөмірін анықтаңыз. Бастапқы мәндер: 1,7; 8,5; 4,25; 1,29; -2,43; 6,6; 7,09; 2,31.

import java.util.Scanner;
public class Esep3 {
public static void main(String[] args)
{
double x[] = new double[8];
Scanner sc = new Scanner(System.in);
for(int i=0; i<8;i++){
System.out.print("x["+i+"]=");
x[i]=sc.nextDouble();
}
int j=0;
double max;
for(int i=0; i<8;i++)
if(x[i]<0) {  j=i; }
for(int i=0; i<8;i++)
System.out.print("a="+x[i]+" ");
System.out.println("\n massivtin teris komponentinin nomiri "+j);
}
}
0
0
336

а1, а2, ..., а10 массиві берілген. Осы массивтің ең үлкен элементін және оның нөмірін табыңыздар. Егер массивте бұндай элемент бірнешеу болса олардың санын анықтаңыздар. Бастапқы мәндер: 7,2; 3,5; -1; 0; 3,3; 6,1; 7,2; -3,6; 5; 7,2.

import java.util.Scanner;
public class Esep2 {
public static void main(String[] args)
{
double a[] = new double[10];
Scanner sc = new Scanner(System.in);
for(int i=0; i<10;i++){
System.out.print("a["+i+"]=");
a[i]=sc.nextDouble();
}
int j=0,k=0;
double max;
max=a[0];
for(int i=1; i<10;i++)
if(a[i]>max) { max=a[i]; j=i; }
for (int i=0;i<10;i++)
if(a[i]==max) k++;
for(int i=0; i<10;i++)
System.out.print("a="+a[i]+" ");
System.out.println("\n massivtin en ulken elementi "+max+" zhane oni nomiri "+j);
System.out.println("Max birdei sandar "+k);
}
}
0
0
1118

Мөлшері m*n берілген А матрицасының кез келген екі бағаналарының орнын ауыстыратын программа жазыңыз.

/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package Nurdaulet; import java.util.Scanner; /** * * @author OOtumbay */ public class Esep1 { public static void main(String[] args) { int a[][] = new int[100][100]; int buf; Scanner s = new Scanner(System.in); System.out.println("m manin engiz-&gt;"); int m = s.nextInt(); System.out.println("n manin engiz-&gt;"); int n = s.nextInt(); System.out.println("massivtin olshemi m = "+m+" n = "+n); for (int i=0; i&lt;m; i++) for (int j=0; j&lt;n; j++) a[i][j] = s.nextInt(); for (int j=0; j&lt;n; j++) { buf=a[j][0]; a[j][0]=a[j][n-2]; a[j][n-2]=buf; } for (int i=0; i&lt;m; i++){ for (int j=0; j&lt;n; j++){ System.out.p…

0
0
490