If I Input
8 5 12 12 15 23 15 18 12 4
It should Output
helloworld
8:8-16-24-32-40-48-56-64
5:5-10-15-20-25
12:12-24-36-48-60-72-84-96-108-120-132-144
12:12-24-36-48-60-72-84-96-108-120-132-144
15:15-30-45-60-75-90-105-120-135-150-165-180-195-210-225
23:23-46-69-92-115-138-161-184-207-230-253-276-299-322-345-368-391-414-437-460-483-506-529
15:15-30-45-60-75-90-105-120-135-150-165-180-195-210-225
18:18-36-54-72-90-108-126-144-162-180-198-216-234-252-270-288-306-324
12:12-24-36-48-60-72-84-96-108-120-132-144
4:4-8-12-16
I think I got the answer but I'm doing something wrong in my code, I'm pretty new to programming still and have been doing fine so far till I encounter the loop and functions.
Here's the closest to what I've got.
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
|
#include<iostream>
#include<iomanip>
using namespace std;
char secretCode(char number)
{
if(number >= 1 && number <= 26)
{
return static_cast<char>('a' - 1 + number);
}
else if (number >= 27 && number <= 52)
{
return static_cast<char>('a' - 27 + number);
}
else if (number >= 53 && number <= 104)
{
return static_cast<char>('a' - 53 + number);
}
}
void printSequence(int number[10])
{
for (int i=0; i<10; i++)
{
cout << secretCode(number[i]);
}
}
int main()
{
int number[10];
for(int x=0; x<10; ++x)
{
cin >> number[x];
printSequence(number);
for(int y=number[x]; y<=number[x]; ++y)
{
for(int z=1; z<=number[x]; ++z)
{
if (z>1)
{
cout << "-";
}
if (z<1)
{
cout <<number[x]*-1;
}
else
cout << number[x]*z ;
}
}
}
}
|