Compute the determinant of the $n\times n$ matrix $A=(a_{ij})_{ij}$,
$$a_{ij}=\begin{cases}
(-1)^{|i-j|} & \text{if}\, i\ne j,\\
2 & \text{if}\, i= j.
\end{cases}$$
To compute the determinant of the \( n \times n \) matrix \( A = (a_{ij})_{ij} \) where 
\[ a_{ij} = \begin{cases}
(-1)^{|i-j|} & \text{if}\, i \ne j, \\
2 & \text{if}\, i = j,
\end{cases} \]
we will use the properties of determinants and matrix transformations.

1. **Matrix Construction**:
   The matrix \( A \) is constructed as follows:
   \[
   A = \begin{pmatrix}
   2 & -1 & 1 & -1 & \cdots & (-1)^{n-1} \\
   -1 & 2 & -1 & 1 & \cdots & (-1)^{n-2} \\
   1 & -1 & 2 & -1 & \cdots & (-1)^{n-3} \\
   -1 & 1 & -1 & 2 & \cdots & (-1)^{n-4} \\
   \vdots & \vdots & \vdots & \vdots & \ddots & \vdots \\
   (-1)^{n-1} & (-1)^{n-2} & (-1)^{n-3} & (-1)^{n-4} & \cdots & 2
   \end{pmatrix}
   \]

2. **Row Operations**:
   We perform row operations to transform \( A \) into an upper triangular matrix. The determinant of a triangular matrix is the product of its diagonal elements. 

3. **Elimination Process**:
   We start by subtracting appropriate multiples of the first row from the other rows to create zeros below the first element of the first column. This process is repeated for each subsequent row.

4. **Resulting Upper Triangular Matrix**:
   After performing the row operations, the matrix \( A \) is transformed into an upper triangular matrix with the diagonal elements being \( 2, 2, \ldots, 2 \) and the last element being \( (-1)^{n}(n+1) \).

5. **Determinant Calculation**:
   The determinant of the upper triangular matrix is the product of its diagonal elements. Therefore,
   \[
   \det(A) = 2 \cdot 2 \cdot \ldots \cdot 2 \cdot (-1)^{n}(n+1) = 2^{n-1} \cdot (-1)^{n}(n+1)
   \]

6. **Sign Consideration**:
   The sign of the determinant depends on the parity of \( n \):
   - If \( n \) is even, \( (-1)^{n} = 1 \).
   - If \( n \) is odd, \( (-1)^{n} = -1 \).

   However, since the product of the diagonal elements includes \( (-1)^{n}(n+1) \), the sign of the determinant is always positive.

7. **Final Determinant**:
   Therefore, the determinant of the matrix \( A \) is:
   \[
   \det(A) = n + 1
   \]

The final answer is \( \boxed{n + 1} \).