Advertisement
Guest User

Untitled

a guest
Nov 27th, 2014
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.59 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. int main(){
  6.     int liczba, a = 0,sprawdzenie=0;
  7.     int tabLiczba[10];
  8.  
  9.     cin >> liczba;
  10.     int kopiaLiczba = liczba;
  11.  
  12.     while (liczba){
  13.         liczba /= 10;
  14.         a++;
  15.     }
  16.  
  17.     liczba = kopiaLiczba;
  18.  
  19.     for (int i = 0; i < 10; i++){
  20.         tabLiczba[i] = liczba % 10;
  21.         liczba /= 10;
  22.     }
  23.    
  24.     for (int i = 0; i <= a; i++){
  25.         if (tabLiczba[i] == tabLiczba[a-1-i])
  26.             sprawdzenie++;
  27.     }
  28.  
  29.     if (sprawdzenie == a){
  30.         cout << "Liczba lustrzana" << endl;
  31.     }
  32.     else
  33.         cout << "Liczba nie jest lustrzana" << endl;
  34.  
  35.  
  36.     system("pause");
  37.     return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement