C语言的排序问题
// sort.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "stdio.h"
//对一个数组的前苦干个数据进行排序
void Sort(int* pData,int iCount)
{
int iTemp;
for(int i= 1; i < iCount;i++)
{
for(int j = iCount-1 ;j >= i;j--)
{
printf ("处理第%d个数据和第%d个数据\n",j,j-1);
if(pData[j] < pData[j-1])
{
iTemp = pData[j-1];
pData[j-1] = pData[j];
pData[j] = iTemp;
}
}
printf ("处理完一轮\n\n");
}
}
//输出一个数组的前苦干个数据
void Print(int* pData,int iCount)
{
for(int i = 0 ; i < iCount ; i++ )
printf("%d ",pData[i]);
}
int main(int argc, char* argv[])
{
int data[] = {16,90,70,18,6,5,4};
//将原始数据输出
printf("原始数据为:\n");
Print(data,7);
printf("\n");
Sort(data,7);
//将排序后的数据输出
printf("排序后的数据为:\n");
Print(data,7);
printf("\n");
return 0;
}
小弟刚开始学C语言两天,看到C语言视频教程里面的排序,我照里面的内容输入为什么会提示错误?
-------------------Configuration: sort - Win32 Debug--------------------
Compiling...
sort.cpp
D:\a\MyProjects\sort\sort.cpp(15) : error C2018: unknown character '0xa3'
D:\a\MyProjects\sort\sort.cpp(15) : error C2018: unknown character '0xac'
D:\a\MyProjects\sort\sort.cpp(15) : error C2146: syntax error : missing ')' before identifier 'j'
D:\a\MyProjects\sort\sort.cpp(15) : error C2059: syntax error : ')'
Error executing cl.exe.
sort.exe - 4 error(s), 0 warning(s)
我看了字母大小和分隔,都一模一样,搞不清楚错在哪,请高手帮忙下