Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- int main()
- {
- string input;
- int jumlahInput = 1;
- cout << "Masukkan Input : ";
- getline(cin, input);
- if (input[0] == '0')
- {
- cout << "Angka pertama tidak boleh nol";
- return 0;
- }
- for (int i = 0; i < input.length(); i++)
- {
- if (input[i] == ' ')
- {
- jumlahInput++;
- if (jumlahInput > 3)
- {
- cout << "Jumlah input maximal 3";
- return 0;
- }
- }
- }
- cout << jumlahInput;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement