-
Notifications
You must be signed in to change notification settings - Fork 0
/
Chapter2Pg66-2.28.cpp
80 lines (74 loc) · 1.58 KB
/
Chapter2Pg66-2.28.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// Peter Danshov
// CST2403 Section 2340
// Assignment 2.28 page 66
// This program takes a five-digit integer input, separates
// the integer into its digits and prints them separated by
// three spaces each.
#include<cstdlib>
#include<iostream>
using namespace std;
int main(int argc, char** argv)
{
int n,o,t,h,th,tth;
cout<<"Please enter a five-digit integer."<<endl;
cin>>n;
o=n%10,t=(n/10)%10,h=(n/100)%10,th=(n/1000)%10,tth=(n/10000)%10;
cout<<tth<<" "<<th<<" "<<h<<" "<<t<<" "<<o<<endl;
return 0;
}
/*
#include<iostream>
#include<vector>
using namespace std;
int main()
{
vector<int> numberlist;
int number,digit;
cout<<"Please enter a five-digit integer: ";
cin>>number;
while(number>0)
{
digit=number%10;
numberlist.push_back(digit);
number=number/10;
}
int length=(int)numberlist.size();
while(length>0,length--)
{
digit=numberlist.pop_back();
cout<<digit;
}
return 0;
}
// Peter Danshov
// CST2403 Section 2340
// Assignment 2.28 page 66
// This program takes an input integer up to ten-digits, separates
// the integer into its digits and prints them separated by
// three spaces each.
#include<iostream>
#include<vector>
using namespace std;
int main()
{
vector<int> numberlist;
int number,digit,length;
cout<<"Please enter a five-digit integer: ";
cin>>number;
while(number>0)
{
digit=number%10;
numberlist.push_back(digit);
number=number/10;
}
cout<<endl;
length=numberlist.size();
for (int i=0; i<length; i++)
{
cout<<numberlist.back()<<" ";
numberlist.pop_back();
}
cout<<endl;
return 0;
}
*/