April Fools Contest 2017, problem: (D) Touchy-Feely Palindromes Solution in C

Affiliate Disclosure: This post contains Amazon affiliate links. If you purchase through these links, eBlogarithm may earn a commission at no extra cost to you. Prices and availability are subject to change.

#include <stdio.h>
#include <string.h>

int main(){
int i, num, flag=0;
char str[11];
scanf(“%s”, str);
num = strlen(str);
if(num == 1){
if(str[0] == ‘3’ || str[0] == ‘7’){
printf(“Yes\n”);
}
else
printf(“No\n”);
}
else{
for(i=0; i<num/2; i++){
if(str[i] == ‘1’ || str[i] == ‘2’){
printf(“No\n”);
flag = 1;
break;
}
if(str[i] == ‘0’){
if(str[num-i-1] != ‘8’){
printf(“No\n”);
flag = 1;
break;
}
}
if(str[i] == ‘3’){
if(str[num-i-1] != ‘3’){
printf(“No\n”);
flag = 1;
break;
}
}
if(str[i] == ‘4’){
if(str[num-i-1] != ‘6’){
printf(“No\n”);
flag = 1;
break;
}
}
if(str[i] == ‘5’){
if(str[num-i-1] != ‘9’){
printf(“No\n”);
flag = 1;
break;
}
}
if(str[i] == ‘6’){
if(str[num-i-1] != ‘4’){
printf(“No\n”);
flag = 1;
break;
}
}
if(str[i] == ‘7’){
if(str[num-i-1] != ‘7’){
printf(“No\n”);
flag = 1;
break;
}
}
if(str[i] == ‘8’){
if(str[num-i-1] != ‘0’){
printf(“No\n”);
flag = 1;
break;
}
}
if(str[i] == ‘9’){
if(str[num-i-1] != ‘5’){
printf(“No\n”);
flag = 1;
break;
}
}
}
if(num%2 == 1 && flag == 0){
if(str[num/2] == ‘0’ || str[num/2] == ‘1’ || str[num/2] == ‘2’ || str[num/2] == ‘4’ || str[num/2] == ‘5’ || str[num/2] == ‘6’ || str[num/2] == ‘8’ || str[num/2] == ‘9’){
printf(“No\n”);
flag = 1;
}
}
if(flag == 0){
printf(“Yes\n”);
}
}
return 0;
}

📦 Looking for April Fools Contest 2017 Problem Touchy? Check the best deals on Amazon.

🛒 Shop April Fools Contest 2017 Problem Touchy on Amazon

As an Amazon Associate, eBlogarithm earns from qualifying purchases. Prices and availability are subject to change.

Affiliate Disclosure: This post contains Amazon affiliate links. If you purchase through these links, eBlogarithm may earn a commission at no extra cost to you. Prices and availability are subject to change.

#include <stdio.h>
#include <string.h>

int main(){
int i, num, flag=0;
char str[11];
scanf(“%s”, str);
num = strlen(str);
if(num == 1){
if(str[0] == ‘3’ || str[0] == ‘7’){
printf(“Yes\n”);
}
else
printf(“No\n”);
}
else{
for(i=0; i<num/2; i++){
if(str[i] == ‘1’ || str[i] == ‘2’){
printf(“No\n”);
flag = 1;
break;
}
if(str[i] == ‘0’){
if(str[num-i-1] != ‘8’){
printf(“No\n”);
flag = 1;
break;
}
}
if(str[i] == ‘3’){
if(str[num-i-1] != ‘3’){
printf(“No\n”);
flag = 1;
break;
}
}
if(str[i] == ‘4’){
if(str[num-i-1] != ‘6’){
printf(“No\n”);
flag = 1;
break;
}
}
if(str[i] == ‘5’){
if(str[num-i-1] != ‘9’){
printf(“No\n”);
flag = 1;
break;
}
}
if(str[i] == ‘6’){
if(str[num-i-1] != ‘4’){
printf(“No\n”);
flag = 1;
break;
}
}
if(str[i] == ‘7’){
if(str[num-i-1] != ‘7’){
printf(“No\n”);
flag = 1;
break;
}
}
if(str[i] == ‘8’){
if(str[num-i-1] != ‘0’){
printf(“No\n”);
flag = 1;
break;
}
}
if(str[i] == ‘9’){
if(str[num-i-1] != ‘5’){
printf(“No\n”);
flag = 1;
break;
}
}
}
if(num%2 == 1 && flag == 0){
if(str[num/2] == ‘0’ || str[num/2] == ‘1’ || str[num/2] == ‘2’ || str[num/2] == ‘4’ || str[num/2] == ‘5’ || str[num/2] == ‘6’ || str[num/2] == ‘8’ || str[num/2] == ‘9’){
printf(“No\n”);
flag = 1;
}
}
if(flag == 0){
printf(“Yes\n”);
}
}
return 0;
}

📦 Looking for April Fools Contest 2017 Problem Touchy? Check the best deals on Amazon.

🛒 Shop April Fools Contest 2017 Problem Touchy on Amazon

As an Amazon Associate, eBlogarithm earns from qualifying purchases. Prices and availability are subject to change.

More from author

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Related posts

Advertismentspot_img

Latest posts

What’s new in Gutenberg 24.0? (16 September)

The WordPress open-source community has officially unveiled Gutenberg 24.0, marking another milestone in the project's biweekly development cycle. This release brings a focused batch...

The Real Truth About Viral Kitchen Gadgets Before You Buy

📢 As an Amazon Associate, I earn from qualifying purchases.After putting the Viral Kitchen Gadgets through a proper 30-day real-world test, I can tell...

Is Viral Kitchen Gadgets Worth Your Money Here Is Our Full Review

📢 As an Amazon Associate, I earn from qualifying purchases.There comes a point when you realise that tolerating a frustrating situation is costing you...

Want to stay up to date with the latest news?

We would love to hear from you! Please fill in your details and we will stay in touch. It's that simple!