Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

#include <stdio.

h>
int soNgayCuaThang(int month, int year){
switch(month){
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
return 31;
case 4:
case 6:
case 9:
case 11:
return 30;
case 2:
return ((year % 400 ==0)||(year%4==0 && year %100 !=0))?29:28;
default:
return -1;}
}
int callDays(int day, int month, int year){
if(day<1 || day>31 ||month <1 || month > 12|| year <1){
return -1;
do{
}while(year<=0);
}
int callDays=0;
for(int i=1;i<month;i++){
callDays+=soNgayCuaThang(i, year);
}
callDays+= day;
return callDays;
}

b11
#include <stdio.h>
int findMax(int N){
int i=1;
int s=0;
while(s<N){
s +=i;
if(s>=N){
i--;
break;
}
i++;
}return i;
}

b12
#include <stdio.h>
int getPower(int x, int y){
int result = 1;
for(int i=0; i<y; i++){
result*=x;
}return result;
}
b13
#include <stdio.h>
void printSquare(int n){
for(int i=1; i<=n; i++) {
for(int j=1; j<=i; j++) {
if(j*j==i)
printf("%d ", i);
}

}
b14
#include <stdio.h>
int UCLN(int a, int b) {
if (b == 0) return a;
return UCLN(b, a % b);
}
int BCNN(int a, int b) {
return (a * b) / UCLN(a, b);
}

You might also like