Programming Basics Retest Assault
ASCII code
AZ 65-90
az 97-122
digits 0-9 48-57
least common divisor
Roll and divide
#include<bits/stdc++.h>
using namespace std;
int gcd(int a,int b)
{
if(a%b!=0)
return gcd(b,a%b);
return b;
}
int main()
{
cout<<"最大公约数"<<gcd(12,16);
cout<<"最小公倍数"<<12*16/gcd(12,16)<<endl;
}
prime number code
int isPrime(int n)
{
if(n<2)
{
return 0;
}
for(int i=2;i<=sqrt(n);i++)
{
if(n%i==0)
return 0;
}
return 1;
}
Judgment of leap year
Ordinary leap year: the Gregorian calendar year is a multiple of 4, and not a multiple of 100, which is an ordinary leap year; century leap year: the Gregorian calendar year is a multiple of hundreds, and must be a multiple of 400 to be a century leap year.
int isrun(int year)
{
if((year%4==0&&year%100!=0)||year%400==0)
return 1;
return 0;
}
triangle area formula
file operation
Functions to read or output a character from a text file