Skip to content

Instantly share code, notes, and snippets.

@definev
Created August 8, 2021 14:39
Show Gist options
  • Save definev/17fe3aea8430d1b77863c32649f8075f to your computer and use it in GitHub Desktop.
Save definev/17fe3aea8430d1b77863c32649f8075f to your computer and use it in GitHub Desktop.
Nộp bài Bùi Đại Dương
/******************************************************************************
Online C Compiler.
Code, Compile, Run and Debug C program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include <stdio.h>
int q1() {
float a, b;
scanf("%f", &a);
scanf("%f", &b);
if (a > b) {
printf("float a>b");
} else {
printf("float a<=b");
}
return 0;
}
int q2() {
int a = 6, b = 2;
printf("a + b = %d\n", a + b);
printf("a - b = %d\n", a - b);
printf("a * b = %d\n", a * b);
printf("a / b = %f", (float) a / b);
return 0;
}
int q3() {
float square;
scanf("%f", &square);
printf("%.2f", square * 4);
return 0;
}
int q4() {
int n;
scanf("%d", &n);
int copyN = n;
int reverseN = 0;
if (n < 0) {
printf("%d is not a palindrome number", n);
} else {
while (copyN > 0) {
reverseN = reverseN * 10 + copyN % 10;
copyN = copyN / 10;
}
reverseN += copyN;
if (reverseN == n) {
printf("%d is a palindrome number", n);
} else {
printf("%d is not a palindrome number", n);
}
}
}
int main()
{
int bai;
printf("Nhập bài số: ");
scanf("%d", &bai);
switch (bai) {
case 1:
return q1();
case 2:
return q2();
case 3:
return q3();
case 4:
return q4();
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment