分类：电脑/网络-程序设计-C/C++
问题：超超超急!!!C++采用筛选法求质数。对已知数组a[]的元素按其 
采用筛选法求质数。对已知数组a[]的元素按其值从小到大的顺序连续编号存于数组b[]，即a[i]的编号存于b[i]。要求a[i]中相等的元素有相同的编号。输入班级全体某门课程的考试成绩，统计各分数得分人数；并以每10为一个分段，统计各分数段以上累计人数。编程：已知汉字点阵信息a，求对a中汉字点阵逆时针旋转90度后的点阵，将结果存于intb[16]中。
回答：//1===============================================#include <tream>using namespace std;#define N 50void main(){  int nSieve[N+1];  nSieve[2] = 1;  for(int i=3; i<=N; i++)    nSieve[i] = i%2;  int nP = 2;  while(nP * nP <= N)  {    //选下一个nP    nP = nP + 1;    while(nSieve[nP] == 0)      nP++;    int t = nP * nP;    int s = 2 * nP;    while(t <= N)    {      nSieve[t] = 0;  //删除      t = t + s;    }  }  for(i=2; i<=N; i++)  {    if(nSieve[i])      cout<<i<<endl;  }}//2===================================================#include <iostream>using namespace std;#define N 10void main(){  int a[N] = {10, 2, 5, 66, 12, 98, 7, 5, 11, 10};  int b[N], nC[N];  for(int i=0; i<N; i++)    nC[i] = 0;  int k = 0;  i = 0;  while( k < N )  {    while(nC[i])      i++;        int nMin = a[i];    int nPos = i;    for(int j=0; j<N; j++)    {      if(nC[j])        continue;            if(nMin > a[j])      {        nMin = a[j];        nPos = j;      }    }    nC[nPos] = 1;    if( a[b[k-1]] == a[nPos] && k > 0 )      b[k] = b[k-1];    else      b[k] = nPos;        k++;  }  for(i=0; i<N; i++)    cout<<a[i]<<",";  cout<<endl;  for(i=0; i<N; i++)    cout<<b[i]<<",";  cout<<endl;}//3===================================================#include <iostream>using namespace std;void main(){  int nNum = 10;  cout<<"学生人数：";  cin>>nNum;  int *pNScore = new int[nNum];  for(int i=0; i<nNum; i++)  {    cout<<"第"<<i+1<<"个学生的分数：";    cin>>pNScore[i];  }  for(i=0; i<nNum-1; i++)  {    for(int j=i+1; j<nNum; j++)    {      if(pNScore[i] > pNScore[j])      {        int nTemp = pNScore[i];        pNScore[i] = pNScore[j];        pNScore[j] = nTemp;      }    }  }  for(i=0; i<nNum; i++)  {    int nScoNum = 1;    for(int j=i+1; j<nNum; j++)    {      if(pNScore[i] == pNScore[j])      {        nScoNum++;        i = j;      }    }    cout<<"得分"<  }  for(i=0; i<100; i+=10)  {    int nStNum = 0;    for(int j=0; j<nNum; j++)    {      if(pNScore[j] >= i && pNScore[j] < i+10)      {        nStNum++;      }    }    cout<<"处于分数段"<<i<<"-"<<i+9<<"的人数为："<<nStNum<<endl;  }    delete [nNum] pNScore;}//4====================================================#include <iostream>using namespace std;void main(){  int a[16] = {0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1};  int b[16];  for(int i=0; i<4; i++)  {    for(int j=0; j<4; j++)    {      b[i*4 + j] = a[j*4 + 3-i];    }  }  for(i=0; i<4; i++)  {    for(int j=0; j<4; j++)    {      cout<<a[i*4 + j]<<",";    }    cout<<endl;  }  cout<<endl;    for(i=0; i<4; i++)  {    for(int j=0; j<4; j++)    {      cout<<b[i*4 + j]<<",";    }    cout<<endl;  }}