Search Header Logo

Mảng tin học

Authored by Tran Quang Huy

Business

1st Grade

Used 1+ times

Mảng tin học
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

34 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Thuật toán nào đúng để tính tích các phần tử có giá trị là số hoàn hảo trong mảng ‘arr’ có 8 phần tử?

int tich=1;

          for(int i=0; i<8; i++)

          {

                    int tonghh=0;

                    for(int j=1; j<=arr[i]/2; j++)

                    if(arr[i]%j!=0) 

                              tonghh=tonghh+j;

                    if(tonghh ==arr[i])

                              tich*=arr[i];

          }

int tich=0;

          for(int i=0; i<8; i++)

          {

                    int tonghh=0;

                    for(int j=1; j<=arr[i]/2; j++)

                    if(arr[i]%j==0) 

                              tonghh=tonghh+j;

                    if(tonghh ==arr[i])

                              tich*=arr[i];

          }

int tich=1;

          for(int i=0; i<8; i++)

          {

                    int tonghh=1;

                    for(int j=1; j<=arr[i]/2; j++)

                    if(arr[i]%j==0) 

                              tonghh=tonghh+j;

                    if(tonghh ==arr[i])

                              tich*=arr[i];

        }

int tich=1;

          for(int i=0; i<8; i++)

          {

                    int tonghh=0;

                    for(int j=1; j<=arr[i]/2; j++)

                    if(arr[i]%j==0) 

                              tonghh=tonghh+j;

                    if(tonghh ==arr[i])

                              tich*=arr[i];

          }

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Thuật toán nào đúng để đếm các phần tử có giá trị là số hoàn hảo trong mảng ‘arr’ có 6 phần tử?

int demhh=0;

          for(int i=0; i<6; i++)

          {

                    int tonghh=0;

                    for(int j=1; j<=arr[i]/2; j++)

                    if(arr[i]%j!=0) 

                              tonghh=tonghh+j;

                    if(tonghh ==arr[i])

                                       demhh++;

          }

int demhh=0;

          for(int i=0; i<=6; i++)

          {

                    int tonghh=0;

                    for(int j=1; j<arr[i]/2; j++)

                    if(arr[i]%j==0) 

                              tonghh=tonghh+j;

                    if(tonghh ==arr[i])

                                       demhh++;

          }

int demhh=0;

          for(int i=0; i<6; i++)

          {

                    int tonghh=0;

                    for(int j=1; j<=arr[i]/2; j++)

                    if(arr[i]%j==0) 

                              tonghh=tonghh+j;

                    if(tonghh ==arr[i])

                                       demhh++;

          }

int demhh=0;

          for(int i=0; i<6; i++)

          {

                    int tonghh=0;

                    for(int j=1; j<=arr[i]/2; j++)

                    if(arr[i]%j==0) 

                              tonghh=tonghh+j;

                    if(tonghh =arr[i])

                                       demhh++;

          }

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Thuật toán nào đúng để hiển thị các phần tử có giá trị là số nguyên tố trong mảng ‘arr’ có 6 phần tử?

for(int i=0; i<6; i++)

          {

                    int dem=0;

                    for(int j=2; j<=sqrt(arr[i]);j++)

                    if(arr[i]%j==0) 

                             dem++;

                    if(dem=0)

                              cout<<arr[i]<<" ";

          }

for(int i=0; i<6; i++)

          {

                    int dem=0;

                    for(int j=2; j<=sqrt(arr[i]);j++)

                    if(arr[i]%j==0) 

                             dem++;

                    if(dem==2)

                              cout<<arr[i]<<" ";

          }

for(int i=0; i<6; i++)

          {

                    int dem=2;

                    for(int j=2; j<=sqrt(arr[i]);j++)

                    if(arr[i]%j==0) 

                             dem++;

                    if(dem==0)

                              cout<<arr[i]<<" ";

          }

for(int i=0; i<6; i++)

          {

                    int dem=0;

                    for(int j=2; j<=sqrt(arr[i]);j++)

                    if(arr[i]%j==0) 

                             dem++;

                    if(dem==0)

                              cout<<arr[i]<<" ";

          }

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Thuật toán nào đúng để tính tích các phần tử có giá trị là số nguyên tố trong mảng ‘arr’ có 7 phần tử?

int  tichnto=0;

          for(int i=0; i<7; i++)

          {

                    int dem=0;

                    for(int j=2; j<=sqrt(arr[i]);j++)

                    if(arr[i]%j==0) 

                             dem++;

                    if(dem==0)

                                       tichnto*=arr[i];

          }

int  tichnto=1;

          for(int i=0; i<7; i++)

          {

                    int dem=0;

                    for(int j=2; j<=sqrt(arr[i]);j++)

                    if(arr[i]%j==0) 

                             dem++;

                    if(dem==0)

                                       tichnto*=arr[i];

          }

int  tichnto=1;

          for(int i=0; i<7; i++)

          {

                    int dem=1;

                    for(int j=2; j<=sqrt(arr[i]);j++)

                    if(arr[i]%j==0) 

                             dem++;

                    if(dem==0)

                                       tichnto*=arr[i];

          }

int  tichnto=1;

          for(int i=0; i<7; i++)

          {

                    int dem=0;

                    for(int j=2; j<=sqrt(arr[i]);j++)

                    if(arr[i]%j=0) 

                             dem++;

                    if(dem==0)

                                       tichnto*=arr[i];

          }

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Thuật toán nào đúng để tính tổng các phần tử có giá trị là số nguyên tố trong mảng ‘arr’ có 5 phần tử?

int  tongnto=0;

          for(int i=0; i<5; i++)

          {

                    int dem=0;

                    for(int j=2; j<=sqrt(arr[i]);j++)

                    if(arr[i]%j==0) 

                             dem++;

                    if(dem==0)

                                       tongnto+=arr[i];

          }

int  tongnto=0;

          for(int i=0; i<5; i++)

          {

                    int dem=0;

                    for(int j=2; j<=sqrt(arr[i]);j++)

                    if(arr[i]%j==0) 

                             dem++;

                    if(dem==2)

                                       tongnto+=arr[i];

          }

int  tongnto=1;

          for(int i=0; i<5; i++)

          {

                    int dem=0;

                    for(int j=2; j<=sqrt(arr[i]);j++)

                    if(arr[i]%j==0) 

                             dem++;

                    if(dem==0)

                                       tongnto+=arr[i];

          }

int  tongnto=0;

          for(int i=0; i<5; i++)

          {

                    int dem=0;

                    for(int j=2; j<=abs(arr[i]);j++)

                    if(arr[i]%j==0) 

                             dem++;

                    if(dem==0)

                                       tongnto+=arr[i];

          }

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Thuật toán nào đúng để đếm số lượng các phần tử có giá trị là số nguyên tố trong mảng ‘arr’ có 5 phần tử?

int  demnto=0;

          for(int i=0; i<5; i++)

          {

                    int dem=0;

                    for(int j=2; j<=sqrt(arr[i]);j++)

                    if(arr[i]%j==0) 

                             dem++;

                    if(dem==0)

                                       demnto++;

          }

int  demnto=1;

          for(int i=0; i<5; i++)

          {

                    int dem=0;

                    for(int j=2; j<=sqrt(arr[i]);j++)

                    if(arr[i]%j==0) 

                             dem++;

                    if(dem==0)

                                       demnto++;

          }

int  demnto=A[0];

          for(int i=0; i<5; i++)

          {

                    int dem=0;

                    for(int j=2; j<=sqrt(arr[i]);j++)

                    if(arr[i]%j==0) 

                             dem++;

                    if(dem==0)

                                       demnto++;

          }

int  demnto=0;

          for(int i=0; i<5; i++)

          {

                    int dem=0;

                    for(int j=2; j<=sqrt(arr[i]);j++)

                    if(arr[i]%j==0) 

                             dem++;

                    if(dem==2)

                                       demnto++;

          }

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Thuật toán nào đúng để sắp xếp mảng `arr` có 8 phần tử theo thứ tự giảm dần bằng thuật toán sắp xếp chọn (Selection Sort)?

for (int i = 0; i < =7; i++) 

          {       

                   int max_idx = 1;   

                   for (int j = i + 1; j <= 8; j++)    

                   if (arr[j] > arr[max_idx])

                             max_idx = j;

                   int temp = arr[i];  

                   arr[i] = arr[max_idx];     

                   arr[max_idx] = temp;     

          }

for (int i = 0; i < 8; i++) 

          {       

                   int max_idx = 0;   

                   for (int j = i + 1; j < 9; j++)      

                   if (arr[j] > arr[max_idx])

                             max_idx = j;

                   int temp = arr[i];  

                   arr[i] = arr[max_idx];     

                   arr[max_idx] = temp;     

          }

for (int i = 0; i < 7; i++) 

          {       

                   int max_idx = i;    

                   for (int j = i + 1; j < 8; j++)      

                   if (arr[j] > arr[max_idx])

                             max_idx = j;

                   int temp = arr[i];  

                   arr[i] = arr[max_idx];     

                   arr[max_idx] = temp;     

          }

for (int i = 0; i < 7; i++) 

          {       

                   int max_idx = i;    

                   for (int j = i + 1; j < 8; j++)      

                   if (arr[j] < arr[max_idx])

                             max_idx = j;

                   int temp = arr[i];  

                   arr[i] = arr[max_idx];     

                   arr[max_idx] = temp;     

          }

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?