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

#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;
}

Advertisement

spot_img

Can a man kill...

Pop culture and action cinema often feed the dramatic...

7 Reasons This Viral...

📢 As an Amazon Associate, I earn from qualifying...

Can you have just...

Welcoming a pet ferret into your home is an...

We Tested Viral Kitchen...

📢 As an Amazon Associate, I earn from qualifying...

7 Reasons This Viral...

📢 As an Amazon Associate, I earn from qualifying...

Building India’s deep-tech enterprise...

India’s startup ecosystem has earned global acclaim for its...

Can a man kill a bear with his hands?

Pop culture and action cinema often feed the dramatic fantasy of human triumph over apex predators, sparking a persistent debate: can a man kill...

7 Reasons This Viral Kitchen Gadgets Is Worth Every Single Penny

📢 As an Amazon Associate, I earn from qualifying purchases.Most products in this category disappoint within weeks. Cheap materials, vague instructions, and results that...

Can you have just one ferret?

Welcoming a pet ferret into your home is an exciting decision, but it frequently prompts an essential question for prospective owners: can you have...

We Tested Viral Kitchen Gadgets Here Is What You Must Know

📢 As an Amazon Associate, I earn from qualifying purchases.If you had told me six months ago that a single purchase would change how...

7 Reasons This Viral Kitchen Gadgets Is Worth Every Single Penny

📢 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...

Building India’s deep-tech enterprise pipeline: from IP to IPO

India’s startup ecosystem has earned global acclaim for its consumer tech and software-as-a-service (SaaS) platforms. However, the nation’s next major economic frontier lies in...

Everything You Need to Know About Viral Kitchen Gadgets Right Now

📢 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...

Dricus Du Plessis Eyes Move to 205lbs Amidst Grueling 45lbs Weight Cut, But Has One Priority First

The grueling reality of mixed martial arts weight cuts often forces fighters to make pivotal career decisions, and reigning UFC star Dricus Du Plessis...

7 Reasons This Viral Kitchen Gadgets Is Worth Every Single Penny

📢 As an Amazon Associate, I earn from qualifying purchases.If you had told me six months ago that a single purchase would change how...