//复习自写
/*
int main()
{ //计算1-100中有多少个9
int i = 0;
int count = 0;
for (i = 1; i <= 100; i++)
{
if (i % 10 == 9)
{
printf("%d ", i);
count++;
}
if (i / 10 == 9)
{
printf("%d ", i);
count++;
}
}
printf("\n%d\n",count);
return 0;
}
*/
/*
int main()
{ //计算100-200中的质数
int i = 0;
int yz = 0;
int count = 0;
for (i = 100; i <= 200; i++)
{
for (yz = 2; yz <= sqrt(i); yz++)
{
if (i%yz == 0)
{
break;
}
}
if(yz>sqrt(i))
{
count++;
printf("%d ",i);
}
}
return 0;
}
*/
/*
int main()
{//计算1/1-1/2+1/3-1/4=...-1/100
int i = 0;
double sum = 0;
int flag = 1;
for (i = 1; i <= 100; i++)
{
sum += flag * 1.0 / i;
flag = -flag;
}
printf("%lf ",sum);
return 0;
}
*/
/*
int main()
{//输出数组中的最大值
int arr[] = { 1,2,3,4,5,6,7,8,9,10 };
//int max =0;//用数组中的值作为对照,防止全为负数时-->max=0影响结果
int max = arr[0];
int i = 0;
int sz = sizeof(arr) / sizeof(arr[0]);
for (i = 0; i < sz; i++)
{
if (arr[i] > max)
{
max = arr[i];
}
}
printf("%d ",max);
return 0;
}
*/
/*
int main()
{ //9*9乘法表
int i = 0;
int j = 0;
for (i = 1; i <= 9; i++)
{
for (j = 1; j <= i; j++)//j<=i -->屏蔽掉7*1的现象
{
printf("%d*%d=%-2d ",i,j,i*j);
}
printf("\n");
}
return 0;
}
*/
/*
void menu()
{
printf("****************************\n");
printf("***1.Play 0.Exit***\n");
printf("****************************\n");
}
void game()
{
printf("猜数字游戏\n");
int ret = 0;
int guess = 0;
ret = rand() % 100 - 1;
while (1)
{
printf("请猜数字:>");
scanf("%d", &guess);
if (guess > ret)
{
printf("猜大了!\n");
}
else if (guess < ret)
{
printf("猜小了!\n");
}
else
{
printf("猜对了!\n");
break;
}
}
}
int main()
{ //猜数字游戏
int input = 0;
srand((unsigned int)time(NULL));
do
{
menu();
printf("请选择:>");
scanf("%d",&input);
switch (input)
{
case 0:printf("退出游戏!\n");
break;
case 1:game();
break;
default:printf("选择错误!\n");
break;
}
}while (input);
return 0;
}
*/
/*
int main()
{ //将数组内字符复制到另一个数组-->strcpy
char arr1[] = "yxy";
char arr2[] = "***" ;
strcpy(arr1,arr2);
printf("%s\n",arr1);
return 0;
}
*/
/*
int is_prime(int n)
{
//2-->n-1
int j = 0;
for (j = 2; j <=sqrt(n);j++)// <=sqrt()--> <n
{
if (n%j == 0)//取余数
return 0;
}
return 1;
}
int main()
{
int i = 0;
for (i = 100; i <= 200; i++)
{
//判断i是否为素数
if (is_prime(i) == 1)
printf("%d ",i);
}
return 0;
}
*/
/*
int is_leap_year(int y)
{
if ((y % 4 == 0 && y % 100 != 0) || (y % 400 == 0))
return 1;//是闰年
else
return 0;//不是闰年
}
int main()
{
int year = 0;
for (year = 1000; year <= 2000; year++)
{
if (is_leap_year(year) == 1)
{
printf("%d ",year);
}
}
return 0;
}
*/
/*
int binary_Search(int arr[], int k,int sz)
{
//int sz = sizeof(arr) / sizeof(arr[0]);//数组传参不能这么使用
int left = 0;
int right =sz - 1;
while (left <= right)
{
int mid = (left + right) / 2;//中间元素的下标
if (arr[mid] < k)
{
left = mid + 1;
}
else if (arr[mid] > k)
{
right = mid - 1;
}
else
{
return mid;
}
}
return -1;
}
int main()
{
//二分查找-->在一个有序数组中查找具体的某个数
int arr[] = { 1,2,3,4,5,6,7,8,9,10 };
int k = 7;
int sz = sizeof(arr) / sizeof(arr[0]);
int ret = binary_Search(arr,k,sz);//arr只代表首元素的地址
if (ret == -1)
{
printf("找不到指定数字\n");
}
else
{
printf("找到了,下标是:%d\n",ret);
}
return 0;
}
*/
/*//每调用一次函数 num+1
void add(int *x)
{
(*x)++;
}
int main()
{
int num = 0;
add(&num);
printf("%d\n",num);
add(&num);
printf("%d\n", num);
add(&num);
printf("%d\n", num);
return 0;
}
*/
/*
int main()
{ //链式访问
int len = 0;
len = strlen("abc");
printf("%d\n",len);
printf("%d\n",strlen("abc"));
return 0;
}
*/
int main()
{
printf("%d",printf("%d",printf("%d",43 )));
//printf("%d",printf("%d",2));
//printf("%d",1);
return 0;//4321 -->printf输出的是输出的个数
}