user-0 提问: 我想在这段代码开头加一个欢迎界面和背景音乐  

回复:
user: user-1
content: VS2015+Windows10 64位编译通过  #include "stdafx.h" #include <Windows.h> #pragma comment(lib,"winmm.lib")  void creat_ShuZu ( 	int num[], int length)//创建长度是length的数组num { 	int i; 	for (i = 0; i<length; ++i) 	{ 		printf("第 %d 个元素：", i + 1); 		scanf_s("%d", &num[i]);  	} 	printf("数组创建完成！\n"); } void jiangXu(int num[], int length)//降序排列数组num中的元素 { 	int i, j; 	int temp;//临时变量  	for (i = 0; i<length - 1; ++i) 	{ 		for (j = i; j<length - 1; ++j) 		{ 			if (num[i] < num[j + 1])//num[i]与num[j+1]值互换 			{ 				temp = num[i]; 				num[i] = num[j + 1]; 				num[j + 1] = temp;  			} 		} 		printf("%d  ", num[i]); 	} 	printf("%d\n", num[9]); } void zheBan_Search(int need_find_num, int num[], int length)//折半查找算法查询整型数字need_find_num是否在数组num中 { 	int low, mid, high; 	int flag = 0; 	low = 1; 	high = length;  	while (low <= high) 	{ 		mid = (low + high) / 2;  		if (need_find_num < num[mid - 1]) 			low = mid + 1;  		else if (need_find_num > num[mid - 1]) 			high = mid - 1; 		else 		{ 			flag = mid; 			printf("查询结果： 找到了,数%d在数组的第%d位\n", need_find_num, flag); 			break; 		}  	} 	if (flag == 0) 		printf("查询结果：  %d不是该数组中的元素\n", need_find_num); }  int main() { 	PlaySound(_T("C:\\See You Again.wav"), NULL, SND_FILENAME | SND_ASYNC | SND_LOOP); 	unsigned timer = 3; 	char op; 	printf("welcome!\n"); 	while (timer != 0) { Sleep(1000); timer--; } 	system("cls"); 	scanf_s("%c", &op); 	if (op == 'q') 		exit(0); 	int num[10]; 	int need_find_num;//需要在数组num中查询的整型数字 	printf("创建一个长度是10的数组: \n"); 	creat_ShuZu(num, 10);  	printf("将数组中的元素降序排列: \n"); 	jiangXu(num, 10);  	char isContinue; 	printf("(y或Y)开始查找，其他退出："); 	fflush(stdin); 	scanf_s("%c", &isContinue); 	while (isContinue == 'y' || isContinue == 'Y') 	{ 		printf("请输入一个要查找的整型数据："); 		scanf_s("%d", &need_find_num); 		printf("折半算法查询%d是否为数组中的一个元素...\n", need_find_num); 		zheBan_Search(need_find_num, num, 10);  		printf("\n\n继续查找？其他退出(Y/y)"); 		fflush(stdin); 		scanf_s("%c", &isContinue);  	} 	printf("已经成功退出！\n");  	return 0; }

user: user-2
content: #include<stdio.h>  void creat_ShuZu(int num[],int length)//创建长度是length的数组num {     int i;      for(i = 0; i<length; ++i) {         printf("第 %d 个元素：", i+1);         scanf("%d", &num[i]);     }     printf("数组创建完成！\n"); } void jiangXu(int num[],int length)//降序排列数组num中的元素 {     int i,j;     int temp;//临时变量      for(i=0; i<length-1; ++i)     {         for(j=i; j<length-1; ++j)         {             if (num[i] < num[j+1])//num[i]与num[j+1]值互换             {                 temp = num[i];                 num[i] = num[j+1];                 num[j+1] = temp;              }         }         printf("%d  ",num[i]);     }     printf("%d\n",num[9]); } void zheBan_Search(int need_find_num,int num[],int length)//折半查找算法查询整型数字need_find_num是否在数组num中 {     int low,mid,high;     int flag = 0;     low = 1;     high = length;      while (low <= high)     {         mid = (low + high)/2;          if (need_find_num < num[mid-1])             low = mid + 1;          else if (need_find_num > num[mid-1])             high = mid - 1;         else         {             flag = mid;             printf("查询结果： 找到了,数%d在数组的第%d位\n",need_find_num,flag);             break;         }      }     if (flag == 0)         printf("查询结果：  %d不是该数组中的元素\n",need_find_num); }  int main(void)//主函数 {     int num[10] ;     int need_find_num;//需要在数组num中查询的整型数字     printf("创建一个长度是10的数组: \n");     creat_ShuZu(num, 10);      printf("将数组中的元素降序排列: \n");     jiangXu(num,10);      char isContinue ;     printf("(y或Y)开始查找，其他退出：");     //fflush(stdin);     getchar();     scanf ("%c",&isContinue);     while (isContinue == 'y' || isContinue == 'Y')     {         printf("请输入一个要查找的整型数据：");         scanf("%d", &need_find_num);         printf("折半算法查询%d是否为数组中的一个元素...\n",need_find_num);         zheBan_Search(need_find_num,num,10);          printf("\n\n继续查找？其他退出(Y/y)");         getchar();         scanf("%c",&isContinue);      }     printf("已经成功退出！\n");      return 0; } 代码编译没有问题；但是运行时，fflush(stdin);这句是想刷新标准输入，清空标准输入，但是实际上使用fflush(stdin)；操作是未定义的，即可能起不到清空输入缓冲的作用；fflush(stdout);刷新标准输出是可以的，对于stdin是未定义的。 建议看一下这个博客； https://my.oschina.net/deanzhao/blog/79790

user: user-0
content: 一直提示void creat 那一行错误

user: user-0
content: 我想把这一段代码放到开头  但是一直错误 #pragma comment(lib,"winmm.lib")  int main() {PlaySound ("C:\See You Again.wav",NULL,SND_FILENAME | SND_ASYNC | SND_LOOP );     unsigned timer=3;   char op;   printf("welcome!\n");   while(timer != 0) { Sleep(1000);timer--; }   system("cls");   scanf("%c",&op);   if(op == 'q')     exit(0);        /* dosomething... */