Results 1 to 4 of 4

Thread: ++

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User Gaming_Cool's Avatar
    Join Date: May:2014
    Location: Plovdiv,Bulgaria
    Posts: 246

    Question ++

    , , . hh:mm:ss, h-; m-;s-.
    : 3695
    : 01:01:35

    , . 01:01:35 1:1:35. , 100% :

    Code:
    #include "stdafx.h"
    #include <iostream>
    
    using namespace std;
    
    int main()
    {
    	int num;
    	int sec;
    	int min;
    	int hour;
    
    	cout << "Enter seconds:";
    	cin >> num;
    	hour = num / 3600;
    	min = (num % 3600) / 60;
    	sec = (num % 3600) % 60;
    
    	if (sec > 9)
    	{
    
    		if (min > 9)
    		{
    
    			if (hour > 9)
    			{
    				cout << hour << ":" << min << ":" << sec << endl;
    				return 0;
    			}
    			cout << "0" << hour << ":" << min << ":" << sec << endl;
    			return 0;
    		}
    		cout << "0" << hour << ":" << "0" << min << ":" << sec << endl;
    		return 0;
    	}
    
    
    	else
    	{
    		cout << "0" << hour << ":" << "0" << min  << ":"<< "0" << sec << endl;
    		return 0;
    	}
    
    	if (min > 9)
    	{
    
    		if (sec > 9)
    		{
    
    			if (hour > 9)
    			{
    				cout << hour << ":" << min << ":" << sec << endl;
    				return 0;
    			}
    			cout << "0" << hour << ":" << "0" << min << ":" << sec << endl;
    			return 0;
    		}
    		cout << "0" << hour << ":" << min << ":" << sec << endl;
    		return 0;
    	}
    	
    	else
    	{
    		cout << "0" << hour << ":" << "0" << min << ":" << "0" << sec << endl;
    		return 0;
    	}
    
    	if (hour > 9)
    	{
    
    		if (sec > 9)
    		{
    
    			if (min > 9)
    			{
    				cout << "0" << hour << ":" << min << ":" << sec << endl;
    				return 0;
    			}
    			cout << "0" << hour << ":" << "0" << min << ":" << sec << endl;
    			return 0;
    		}
    		cout << hour << ":" << min << ":" << sec << endl;
    		return 0;
    	}
    	else
    	{
    		cout << "0" << hour << ":" << "0" << min << ":" << "0" << sec << endl;
    	}
        return 0;
    }
    3695 , 2345 00:039:05. . .

  2. #2
    Jedem das Seine Glimmer's Avatar
    Join Date: Jun:2004
    Location:
    Posts: 1,136
    Code:
    #include <iostream>
    #include <iomanip>
    
    using namespace std;
    
    int main() {
    
        uint32_t timeSec;
    
        cout << "Enter seconds:";
        cin >> timeSec;
    
        cout.fill('0');
        cout << setw(2) << timeSec / 3600 << ':'
             << setw(2) << timeSec % 3600 / 60 << ':'
             << setw(2) << timeSec % 3600 % 60 << endl;
    
        return 0;
    }
    DX58SO | x5670@4.2 | Megahalems | 3x4 EBJ40EG8BFWB-JS-F@1400 MHz | MSI GTX 970 1488/8000 | THNSNH256GBST + 3 x WD1600HLHX RAID 0 | X-Fi Titanium | P1-1250-BEFX
    The big trouble with dumb bastards is that they are too dumb to believe there is such a thing as being smart. Kurt Vonnegut

  3. #3
    Registered User postscriptum's Avatar
    Join Date: Mar:2006
    Location: Shinra Labs
    Posts: 644
    . if - , ( ). - if, ...
    ( ) , else...

  4. #4
    Registered User Gaming_Cool's Avatar
    Join Date: May:2014
    Location: Plovdiv,Bulgaria
    Posts: 246
    , postscriptum! .

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Copyright © 1999-2011 . .
iskamPC.com | mobility.BG | Bloody's Techblog | | 3D Vision Blog |