-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprintFormat.cpp
More file actions
71 lines (58 loc) · 953 Bytes
/
printFormat.cpp
File metadata and controls
71 lines (58 loc) · 953 Bytes
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
#include <iostream>
#include <cstring>
#include <windows.h>
#include <time.h>
const int LOOP_COUNT = 512;
template <class T>
void printFormat(const char* format, T arg)
{
for (int i = 0; i < strlen(format); i++)
{
if (format[i] == '%')
{
switch (format[i + 1])
{
case 'v':
std::cout << arg;
i++;
break;
default:
std::cout << format;
break;
}
}
else
{
std::cout << format[i];
}
}
}
template <class T>
void input(T* t)
{
std::cin >> *t;
}
int main()
{
srand((unsigned int)time(NULL));
int i, j, k, l;
int x = 5;
char c = 97;
char str1[13] = "~@# ^&$ !##@";
char str2[7] = " *( )";
std::cout << x << std::endl;
printFormat("x : %v\n", x);
printFormat("c : %v\n", c);
int ran = rand() % 10;
printFormat("ran : %v\n>> ", ran);
input(&ran);
while (ran)
{
i++;
j += i * 2;
k += j * 2;
l += k * 2;
printFormat("*%v* _ * *__ *", l);
}
return 0;
}