SubhanXd
Centipat
- Katılım
- 5 Kasım 2022
- Mesajlar
- 151
Selamlar. Yapmam gereken:
"Given an array of integers, check if the values of array elements are symmetrical. An array is considered symmetrical if it reads the same from left to right and from right to left."
Kodum:
"Given an array of integers, check if the values of array elements are symmetrical. An array is considered symmetrical if it reads the same from left to right and from right to left."
Kodum:
C++:
int main() {
int size;
cin>>size;
int counter = 0 ;
int array[size];
for(int f = 0 ; f<size ; ++f) {
cin >> array[f] ;
}
bool marker = false ;
for (int f = 0 ; f < size ; ++f) {
for (int s = size ; s == 0 ; --s) {
if (array[f] == array[s]) {
marker = true ;
}
if (marker) {
++counter ;
}
}
}
if (counter==size) {
cout << "Symmetrical" << endl ;
} else {
cout << "Not Symmetrical" << endl ;
}
}
Son düzenleyen: Moderatör: