Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pch.h"
- #include <iostream>
- using namespace std;
- int main()
- {
- int k, n;
- int nMultipli = 0; // Gli n numeri multipli di k
- cout << "Inserisci k: ";
- cin >> k;
- while (k < 1)
- {
- cout << "Errore, k deve essere maggiore di 0." << endl;
- cout << "Inserisci k: ";
- cin >> k;
- }
- do
- {
- cout << "Inserisci n: ";
- cin >> n;
- while (n == 0)
- {
- cout << "n non puo' essere 0. Immettilo negativo per uscire o positivo per continuare." << endl;
- cout << "Inserisci n: ";
- cin >> n;
- }
- if (n % k == 0)
- {
- nMultipli++;
- }
- } while (n > -1);
- cout << "I numeri multipli di " << k << " sono " << nMultipli << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement