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ử?

Mảng tin học

Quiz
•
Business
•
1st Grade
•
Easy
Tran Quang Huy
Used 1+ times
FREE Resource
34 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
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;
}
Create a free account and access millions of resources
Similar Resources on Quizizz
30 questions
Manajemen Lintas Budaya

Quiz
•
1st - 10th Grade
33 questions
Tập huấn SME VCB LA

Quiz
•
1st - 5th Grade
35 questions
3.4 Test Keseimbangan Pasar dan Struktur Pasar Kls X

Quiz
•
1st Grade
29 questions
Finanzas

Quiz
•
1st Grade
36 questions
Math

Quiz
•
1st Grade
30 questions
ITB TUTORIAL ASSIGNMENT

Quiz
•
1st Grade
30 questions
商业学 >2019巴生滨华中学毕业考

Quiz
•
1st - 5th Grade
30 questions
DS Business Part C v2

Quiz
•
1st - 12th Grade
Popular Resources on Quizizz
10 questions
Chains by Laurie Halse Anderson Chapters 1-3 Quiz

Quiz
•
6th Grade
20 questions
math review

Quiz
•
4th Grade
15 questions
Character Analysis

Quiz
•
4th Grade
12 questions
Multiplying Fractions

Quiz
•
6th Grade
30 questions
Biology Regents Review #1

Quiz
•
9th Grade
20 questions
Reading Comprehension

Quiz
•
5th Grade
20 questions
Types of Credit

Quiz
•
9th - 12th Grade
50 questions
Biology Regents Review: Structure & Function

Quiz
•
9th - 12th Grade
Discover more resources for Business
10 questions
Identifying equations

Quiz
•
KG - University
20 questions
r- controlled vowels review!

Quiz
•
1st - 2nd Grade
12 questions
Summer Trivia

Quiz
•
1st - 5th Grade
15 questions
Disney Trivia

Quiz
•
KG - 5th Grade
10 questions
Nouns, Verbs, and Adjectives

Quiz
•
1st - 2nd Grade
13 questions
addition and subtraction

Quiz
•
1st Grade
15 questions
First Grade Ready Math Unit 6 Review

Quiz
•
1st Grade
10 questions
Pixar Short "Piper"

Quiz
•
KG - 2nd Grade