forked from uva-cs/pdr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
inlab4.cpp
49 lines (38 loc) · 1.9 KB
/
inlab4.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
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;
void tableDump(string (*arr)[5], string (*arr1)[4]);
int main(){
// Replace the empty strings below with
// the values you found while experimenting.
string nonPointers[6][5] = {
{"int", "" /*size*/, "" /*max value*/, "" /*zero as stored in hex*/,"" /*one as stored in hex*/},
{"unsigned int", "" /*size*/, "" /*max value*/, "" /*zero as stored in hex*/, "" /*one as stored in hex*/},
{"float", "" /*size*/, "" /*max value*/, "" /*zero as stored in hex*/, "" /*one as stored in hex*/},
{"double", "" /*size*/, "" /*max value*/, "" /*zero as stored in hex*/, "" /*one as stored in hex*/},
{"char", "" /*size*/, "" /*max value*/, "" /*zero as stored in hex*/, "" /*one as stored in hex*/},
{"bool", "" /*size*/, "" /*max value*/, "" /*zero as stored in hex*/, "" /*one as stored in hex*/},
};
string pointers[3][4] = {
{"int*", "" /*size*/, "" /*max value*/, "" /*NULL as stored in hex*/},
{"char*", "" /*size*/, "" /*max value*/, "" /*NULL as stored in hex*/},
{"double*", "" /*size*/, "" /*max value*/, "" /*NULL as stored in hex*/},
};
tableDump(nonPointers, pointers);
return 0;
}
void tableDump(string (*arr)[5], string (*arr1)[4]){
for(int i = 0; i < 6; i++){
printf("Size of %s: %s\n", arr[i][0].c_str(), arr[i][1].c_str());
printf("Max value of %s: %s\n", arr[i][0].c_str(), arr[i][2].c_str());
printf("Zero of type %s is stored as: %s\n", arr[i][0].c_str(), arr[i][3].c_str());
printf("One of type %s is stored as: %s\n", arr[i][0].c_str(), arr[i][4].c_str());
}
printf("-----------------------------------------------------------------------------\n");
for(int i = 0; i < 4; i++){
printf("Size of %s: %s\n", arr[i][0].c_str(), arr[i][1].c_str());
printf("Max value of %s: %s\n", arr[i][0].c_str(), arr[i][2].c_str());
printf("NULL of type %s is stored as: %s\n", arr[i][0].c_str(), arr[i][1].c_str());
}
}