Covering what others suggested (e.g. @Srivaths), please follow at least PEP8 Python PEP8
Then, put your code in some function.
Give meaningful names to variables. (What's a, c, x, z ... why are you not using b? )
You don't need import math -- instead of f=row/2
f=math.ceil(f), you can do f = row // 2 (assuming you use python 3).
Note that you can solve ...
As @JanKuiken mentioned, your idea is probably clever, but I can't understand what your code does either! Please add it to the question if possible!
You need more spaces in your code!
Prefer += and -= operators as they are more compact than assignments such as x = x + 1.
for variable in range(0, end) is not necessary as range starts the sequence with 0 by ...
Create a class Matrix
Instead of having a vector of vectors, and have global functions that manipulate those, create a class Matrix and add member functions to it to manipulate matrices. You should probably also create overloads for arithmetic operations, so you can write things like auto matrix3 = matrix1 + matrix2;
Have a look at existing C++ matrix ...
Some comments, more about methods that about the code.
Personally I would have called it Rational since that what it is: rational numbers. But this is a matter of taste.
The constructor should assert that _den != 0.
The operator!= should compare the simplified fractions.
Should it not be lcm (lowest common multiple) and gcd (greatest common ...
If your input is 2-dimensional, you can get away with a much simpler solution (although you need to know the pad length).
import numpy as np
# Test Case:
data = [
[1, 2, 3]
max_len = 3
# General Solution:
rectangle = np.zeros((len(data), max_len), dtype=np.int)
for i in range(len(data)):
rectangle[i:i + 1, 0:len(data[i])] = ...
using namespace std;
Never do that; certainly not in a header - that inflicts the harm onto every source file that includes the header.
Prefer to include your own headers before Standard Library headers. This can help expose unsatisfied dependencies of your library's headers.
Prefer <cmath> to <math.h> (etc.), as this puts the standard ...