CREATE TABLE `Traveller` ( userid INTEGER NOT NULL, name VARCHAR(30) NOT NULL, email VARCHAR(30), PRIMARY KEY (userid) );
CREATE TABLE `Hotel` ( Hotelid INTEGER NOT NULL, HotelName VARCHAR(30) NOT NULL, City VARCHAR(30) NOT NULL, lowestP INTEGER, PRIMARY KEY (Hotelid) );
CREATE TABLE `Room` ( roomid INTEGER NOT NULL, adultsNum INTEGER NOT NULL, childrenNum INTEGER NOT NULL, roomType VARCHAR(30) NOT NULL, Hotelid INTEGER NOT NULL, PRIMARY KEY (roomid,Hotelid) );
CREATE TABLE `Reservation` ( reservationid INTEGER NOT NULL, checkinDate DATE NOT NULL, checkoutDate DATE NOT NULL, price INTEGER NOT NULL, userid INTEGER NOT NULL, Hotelid INTEGER NOT NULL, roomid INTEGER NOT NULL, PRIMARY KEY (reservationid) );
CREATE INDEX idxReservation1 ON Reservation ( userid );
CREATE TABLE `CreditCard` ( cardid INTEGER NOT NULL, cardNumber VARCHAR(30) NOT NULL, cardHolderAddress VARCHAR(30), userid INTEGER NOT NULL, PRIMARY KEY (cardid) );
CREATE INDEX idxCreditCard1 ON CreditCard ( userid );
Implement atoi which converts a string to an integer.
The function first discards as many whitespace characters as necessary until the first non-whitespace character is found. Then, starting from this character, takes an optional initial plus or minus sign followed by as many numerical digits as possible, and interprets them as a numerical value.
The string can contain additional characters after those that form the integral number, which are ignored and have no effect on the behavior of this function.
If the first sequence of non-whitespace characters in str is not a valid integral number, or if no such sequence exists because either str is empty or it contains only whitespace characters, no conversion is performed.
If no valid conversion could be performed, a zero value is returned.
Note: Assume we are dealing with an environment which could only store integers within the 32-bit signed integer range: [−231, 231 − 1]. If the numerical value is out of the range of representable values, INT_MAX (2^31 − 1) or INT_MIN (−2^31) is returned. 简单的说就是把一个string转为int
The string “PAYPALISHIRING” is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)
And then read line by line: “PAHNAPLSIIGYIR”
Write the code that will take a string and make this conversion given a number of rows:
1
string convert(string s, int numRows);
样例如下
Example 1:
1 2
Input: s = "PAYPALISHIRING", numRows = 3 Output: "PAHNAPLSIIGYIR"
Example 2:
1 2
Input: s = "PAYPALISHIRING", numRows = 4 Output: "PINALSIGYAHRPI"