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 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214
|
#include <cstdio>
#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <string>
#include <cstring>
#include <fstream>
#include <sstream>
using namespace std;
int main () {
int pg_num, num_of_pg, pg_counter = 1, pg_num_minus, pg_num_plus;
// pg_num is the number of the current page being made
//
// num_of_pg is the number of the number of pages being added to the gallery
//
// pg_counter is an int variable used to keep track of how many pages have been made, and
// is also used to stop the loop when the right amount of pages have been made
//
// pg_num_minus is an int variable used to set up the string pg_label_minus to
// hold one integer less than the current page's number value
//
// pg_num_plus is an int variable used to set up the string pg_label_plus to
// hold one integer more than the current page's number value
string pg_name = ("page_00.html"),
strg,
pg_label,
pg_labeled,
pg_label_minus,
pg_label_plus,
pg_labeled_minus,
pg_labeled_plus;
// pg_name is a string that holds a template for the page names
//
// strg is a string that holds the name of the current page being made
//
// pg_label is a string that takes in the int value of the current page being made
//
// pg_labeled is a string that takes in the value of the pg_label, but
// it does it with either the "=" or the "+=" methods, depending on
// if the value of pg_num is less than 10 or not
//
// pg_label_minus is a string that takes in either the value of pg_num_minus, or,
// if the current page being written is to be the first page in the gallery,
// it takes in the value of the last page to be written, so that the gallery
// loops to the last page in the gallery when you click the "previous page"
// link from the first page in the gallery.
//
// pg_label_plus is a string that takes in either the value of pg_num_plus, or,
// if the current page being written is to be the last page in the gallery,
// it takes in the value of the first page in the gallery, meaning the page number 01
//
// pg_labeled_minus is a string that is the final version of the string that holds
// one int less than the page number; this is also used to take into account the
// possiblility that the number of pages could be less than 10,
// and if so, then it takes in a zero into the tens digit place
//
// pg_labeled_plus is a string that is the final version of the string that holds
// one int more than the page number
cout << endl << endl;
cout << "input the number of the newest page in the gallery in two digit format\n"
<< "the first page made once this program does its work" << endl << endl;
cin >> pg_num;
cout << endl << "input the number of pages to be added to the gallery" << endl << endl;
cin >> num_of_pg;
cout << endl << endl;
do
{
pg_labeled = ("0"),
pg_labeled_minus = ("0"),
pg_labeled_plus = ("0");
stringstream ss;
ss << pg_num;
ss >> pg_label;
string strg = pg_name;
if(pg_num < 10)
{
pg_labeled += pg_label;
}
else
{
pg_labeled = pg_label;
}
strg.replace(5, 2, pg_labeled);
pg_num_minus = pg_num;
pg_num_plus = pg_num;
stringstream gg;
gg << pg_num_minus - 1;
gg >> pg_label_minus;
stringstream nn;
nn << pg_num_plus + 1;
nn >> pg_label_plus;
if (pg_num == 01)
{
string pg_link_last, pg_link_final, pg_link_final_tens = ("0");
stringstream ff;
ff << num_of_pg;
ff >> pg_link_last;
pg_link_final = pg_link_last;
if (num_of_pg%10 == 0)
{
strg.replace(0, 1, pg_link_final_tens);
}
pg_labeled_minus = pg_link_final;
pg_labeled_plus += pg_label_plus;
}
else if(pg_num == num_of_pg)
{
string pg_one = ("01");
pg_labeled_plus = pg_one;
pg_labeled_minus = pg_label_minus;
}
else if(pg_num < 9)
{
pg_labeled_minus += pg_label_minus;
pg_labeled_plus += pg_label_plus;
}
else if (pg_num == 9 || pg_num == 10)
{
pg_labeled_minus += pg_label_minus;
pg_labeled_plus = pg_label_plus;
}
else
{
pg_labeled_minus = pg_label_minus;
pg_labeled_plus = pg_label_plus;
}
ofstream img_pg_writer;
img_pg_writer.open (strg.c_str());
img_pg_writer << "<html>" << endl;
img_pg_writer << "<head>" << endl;
img_pg_writer << "<title> page "<< pg_label << " </title>" << endl;
img_pg_writer << "<link rel=\"stylesheet\" type=\"text/css\"";
img_pg_writer << " href=\"gallery.css\" />" << endl;
img_pg_writer << "</head>" << endl;
img_pg_writer << "<body>" << endl;
img_pg_writer << endl;
img_pg_writer << "<a align=\"left\" href=\"page_" << pg_labeled_minus <<;
img_pg_writer << ".html\"> previous picture </a>..." << endl;
img_pg_writer << endl;
img_pg_writer << "<a align=\"left\" href=\"index.html\"> ";
img_pg_writer << "index page </a>" << endl;
img_pg_writer << endl;
img_pg_writer << "<a align=\"center\" href=\"page_" << pg_labeled_plus <<;
img_pg_writer << ".html\"><img src=\"image_" << pg_labeled <<;
img_pg_writer << ".jpg\" alt=\"image_" << pg_labeled <<;
img_pg_writer << ".jpg\"></a>" << endl;
img_pg_writer << endl;
img_pg_writer << "<a align=\"right\" href=\"index.html\"> index page";
img_pg_writer << " </a>..." << endl;
img_pg_writer << endl;
img_pg_writer << "<a align=\"right\" href=\"page_" << pg_labeled_plus <<;
img_pg_writer << ".html\"> next picture </a>" << endl;
img_pg_writer << endl;
img_pg_writer << "</body>" << endl;
img_pg_writer << "</html>";
img_pg_writer.close();
pg_label.clear();
pg_labeled.clear();
pg_labeled_minus.clear();
pg_labeled_plus.clear();
pg_counter++;
ss << ++pg_num;
ss >> pg_label;
}while(num_of_pg >= pg_counter);
system("pause");
return 0;
}
|