(arr[i]==value)
{
return i;
}
}
return index;
}
int main()
{
int arr[5]={3,12,9,8,6};
int value = 8;
int index =getIndex(arr,value);
if(index!=-1)
{
printf("%d在数组中存在,下标为 %d\n",value,index);
}
else
{
printf("%d在数组中不存在.\n",value);
}
return 0;
}
{
return i;
}
}
return index;
}
int main()
{
int arr[5]={3,12,9,8,6};
int value = 8;
int index =getIndex(arr,value);
if(index!=-1)
{
printf("%d在数组中存在,下标为 %d\n",value,index);
}
else
{
printf("%d在数组中不存在.\n",value);
}
return 0;
}
2021-10-09
for(j=0;j>=0;j++)
{
if(arr[j]>arr[j+1]) //当前面数比后面的数大时
{
double temp; //定义临时变量temp
temp = arr[j]; //讲前面的数赋值给temp
arr[j] = arr[j+1]; //前后之数颠倒位置
arr[j+1] =t
{
if(arr[j]>arr[j+1]) //当前面数比后面的数大时
{
double temp; //定义临时变量temp
temp = arr[j]; //讲前面的数赋值给temp
arr[j] = arr[j+1]; //前后之数颠倒位置
arr[j+1] =t
2021-10-08
#include <stdio.h>
int main()
{
char c = 'a';
int n = c; //将c赋值给n
float f = c; //将c赋值给f
double d = c; //将c赋值给d
printf("%d\n",n);
printf("%f\n",f);
printf("%lf\n",d);
return 0;
}
//ASCII中字符‘a’的编号是97
//结果
int main()
{
char c = 'a';
int n = c; //将c赋值给n
float f = c; //将c赋值给f
double d = c; //将c赋值给d
printf("%d\n",n);
printf("%f\n",f);
printf("%lf\n",d);
return 0;
}
//ASCII中字符‘a’的编号是97
//结果
2021-09-23
#include <stdio.h>
int getWordNumber(int n)
{
if(n == 1)
{
return 1;
}
else{
return getWordNumber (n-1) +n;
}
}
int main()
{
int num = getWordNumber(10);
printf("小明第10天记了:%d个单词.\n",num);
return 0;
}
int getWordNumber(int n)
{
if(n == 1)
{
return 1;
}
else{
return getWordNumber (n-1) +n;
}
}
int main()
{
int num = getWordNumber(10);
printf("小明第10天记了:%d个单词.\n",num);
return 0;
}
2021-09-21
#include<stdio.h>
int main()
{
int a,b,c;
for(a=1;a<=4;a++)
{
for(b=1;b<5-a;b++)
{
printf(" ");
}
for(c=1;c<=2*a-1;c++)
{
printf("*");
}
printf("\n");
}
return 0;
}
int main()
{
int a,b,c;
for(a=1;a<=4;a++)
{
for(b=1;b<5-a;b++)
{
printf(" ");
}
for(c=1;c<=2*a-1;c++)
{
printf("*");
}
printf("\n");
}
return 0;
}
2021-09-18