标签:ddr 机器 pre 广播 硬件 toc 网通 com 了解
最小公约数
#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
int main()
{
int num1 = 0;
int num2 = 0;
int r = 0;
printf("最小公约数");
scanf("%d%d", &num1, &num2);
while (num1%num2)
{
r = num1%num2;
num1 = num2;
num2 = r;
}
printf("完毕%d\n",num2);
return 0;
}
判断闰年
#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
int main()
{
int year = 0;
int count = 0;
for (year= 1000; year <=2000; year++)
{
if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0))
{
printf(" %d年", year);
count++;
}
/*if (year % 4 == 0 && year % 100 != 0)
{
printf(" %d年", year);
count++;
}
else if (year % 400 == 0)
{
printf(" %d年", year);
count++;
}*/
}
printf("\n");
printf("一共有%d个闰年\n", count);
return 0;
}
试初法找素数
#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <math.h>
int main()
{
int i = 0;
int count = 0;
for ( i = 100; i <=200; i++)
{
int j = 0;
for (j = 2; j < sqrt(i); j++)
{
if (i%j == 0)
{
break;
}
}
if (j>sqrt(i))
{
count++;
printf("%d ", i);
}
}
return 0;
}
1~100出现9的次数
#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <math.h>
int main()
{
int a = 0;
int i = 0;
int num1 = 0;
for ( i = 0; i <= 100; i++)
{
if (i%10==9)//i-9%10==0也可以
{
num1++;
printf("%d ", i);
}
if(i / 10 == 9)
{
num1++;
printf("%d ", i);
}
}
printf("出现了%d次\n", num1);
return 0;
}
#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <math.h>
int main()
{
int i = 0;
double num1 = 0.0;
int flag = 1;
for ( i = 1; i <= 100; i++)
{
num1 += flag*1.0 / i ;
flag = -flag;
}
printf("%lf\n",num1);
return 0;
}
9x9乘法表
#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <math.h>
int main()
{
int i = 0;
printf("九九乘法表\n");
for ( i = 1; i <=9; i++)
{
int j = 1;
for ( j = 1; j <=i; j++)
{
int max = j*i;
printf("%d*%d=%-2d ", i, j, max);
}
printf("\n");
}
return 0;
}
标签:ddr 机器 pre 广播 硬件 toc 网通 com 了解
原文地址:https://blog.51cto.com/14890690/2517749