jurys71242
?>

Сдиапазоном от 1 до n посчитать количество чисел кратных 3, 11, 13 с циклами

Информатика

Ответы

abrolchik8511
Basic:

DIM n as integer, kratnoe, howMuch
INPUT "Введите N"; n
INPUT "Введите, чему должны быть кратны числа"; kratnoe
FOR i = 1 TO n
IF i MOD kratnoe = 0 THEN
howMuch = howMuch + 1
END IF
NEXT i
PRINT howMuch

C#:

int n = int.Parse(Console.ReadLine());
int kratnoe = int.Parse(Console.ReadLine());
int howMuch = 0;

for (i = 0; i < n; i++)
{
     if (n % kratnoe == 0)
    {
         howMuch++;
    }
}

Console.WriteLine(howMuch);
Console.ReadLine();
Donat-Evgeniya793
#include <iostream>#include <time.h>#include <stdio.h>#include <stdlib.h>#define max 100using 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) { srand(time(NULL)); int n , Chet = 0 ,notChet = 0 ,a[max]; cout<<"Size : "; cin>>n; for(int i = 0; i < n; i++) { a[i] = rand()%120+20; cout<<a[i]<<endl; if (a[i] %2 == 0) Chet++; else notChet++; } cout<<"Chet = "<<Chet<<", NotChet = "<<notChet; return 0;}
argo951385
1)
typedef size_t uint32; 
mt19937 gen{ random_device()() }; 
uniform_int_distribution<uint32> uid(20, 100); 
const uint32 N = 10;     
int main() 
{
     uint32 arr[N], pos{0}, neg{0};
     for (uint32 i = 0; i < N; ++i) {
         arr[i] = uid(gen);
         cout << arr[i] << " ";
         if (arr[i] % 2 == 0) ++pos;
         else ++neg;
     }
     cout << endl << pos << "/" << neg << endl;
     system("pause"); 
}
2)
typedef size_t uint32; 
mt19937 gen{ random_device()() }; 
uniform_int_distribution<uint32> uid(0, 100); 
const uint32 N = 10;     
int main() 
{
     uint32 arr[N], lf{ 0 }, hf{ 0 }, sum1{ 0 }, sum2{ 0 };
     for (uint32 i = 0; i < N; ++i) {
         arr[i] = uid(gen);
         cout << arr[i] << " ";
         if (arr[i] >= 50) {
             ++lf;
             sum1 += arr[i];
         } else {
             ++hf;
             sum2 += arr[i];
         }
     }
     cout << endl << sum1 / lf << "/" << sum2 / hf << endl;
     system("pause"); 
}

Ответить на вопрос

Поделитесь своими знаниями, ответьте на вопрос:

Сдиапазоном от 1 до n посчитать количество чисел кратных 3, 11, 13 с циклами
Ваше имя (никнейм)*
Email*
Комментарий*

Популярные вопросы в разделе

ganul
veraplucnika
Кириллов57
happych551
rusvicktor
lenalevmax7937
Vasilevna_Shabanova1502
stepanova-natalie
lazaren-ko
innavinogradova1385
Artak96993298
maksimovskiy7657
vera-classic75
nastya3213868
UvarovAndrei