Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /******************************************************************************
- Online C++ Compiler.
- Code, Compile, Run and Debug C++ program online.
- Write your code in this editor and press "Run" button to compile and execute it.
- *******************************************************************************/
- #include <iostream>
- using namespace std;
- bool
- isPrime (int n)
- {
- for (int i = 2; i <= (n / 2); ++i)
- {
- if ((n % i) == 0)
- {
- return false;
- }
- }
- return true;
- }
- int
- main ()
- {
- int end;
- cout<<"Masukkan nilai akhir:";
- cin >> end;
- //i j k l m n o p
- for (int i = 0; i < end; i++)
- {
- //jika ganjil maka *, selainnya #;
- if (i % 2)
- {
- //print desimal
- for (int j = end; j >= 1; j--)
- {
- cout << j;
- }
- cout << endl;
- for (int j = 1; j <= end; j++)
- {
- cout << "*";
- }
- }
- else
- {
- //print desimal tapi kebalik
- for (int j = 1; j <= end; j++)
- {
- cout << j;
- }
- cout << endl;
- for (int j = 1; j <= end; j++)
- {
- cout << "#";
- }
- }
- cout << endl;
- for(int j = 2,k=1; k <= end;j++)
- {
- if(isPrime(j))
- {
- cout<<j;
- k++;
- }
- }
- cout<<endl;
- for(int j = 0; j< end; j++)
- {
- cout<<end-i;
- }
- cout<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement