Beginners Task #2

Online C++ programming contests.

Moderators: Darobat, RecursiveS, Dante Shamest, Bugdude, Wizard, raimo

Postby Fossil » Mon Oct 10, 2005 12:55 pm

Code: Select all
#include <iostream>

int main()
{
    long chx=2,inp=1;                   //set var
    std::cout<<"Please type in a number\n";     
    std::cin>>inp;
  for(;;)                               //loop forever
    {
        if (bool(inp%chx)){chx++;continue;}   //is divisable?     
        std::cout<<chx;
        if (inp==chx)
        {std::cout<<" Prime Factors.";break;} //The end??
        inp=inp/chx;              //if not carry on                       
        std::cout<<"*";
    }     
    std::cin>>inp;     //leave on screen not the best way!!
    return 0;
}

My twopennith,and its not idiot proof
Fossil
 
Posts: 4
Joined: Thu Oct 06, 2005 12:12 pm

Previous

Return to Contests

Who is online

Users browsing this forum: No registered users and 1 guest