#pragma region TraceMe
////#include <stdio.h>
////#include<string.h>
////#include<windows.h>
////unsigned char Table[8] = {0xC,0xA,0x13,0x9,0xC,0xB,0xA,0x8};
////int main()
////{
//// printf(" input Name\n");
//// char *s;
//// char st[10];
//// scanf_s("%st",&st);
//// s = st;
//// int len;
//// len = strlen("st");
//// int i,j;
//// unsigned long code=0;
////
//// for(i=3,j=0;i<len;i++,j++)
//// {if(j>7) j=0;
//// code+=(s[i])*Table[j];
//// }
////
//// wsprintf((TCHAR*)s,TEXT("%ld"),code);
//// printf("%ld",*s);
//// getchar();
//// return 0;
////}
#pragma endregion
#pragma region
//
//#include<stdio.h>
//#include<iostream>
//#include<string>
//#include <iomanip>
//using namespace std;
//class StuData
//{
//private:
// string name;
// string sex;
// int id;
// int result[4];
//public:
// StuData();
// void get();
// string getname();/*得到名字这样的函数叫常成员函数。常成员函数可以理解为是一个“只读”函数,
// 它既不能更改数据成员的值,也不能调用那些能引起数据成员值变化的
// 成员函数,只能调用const成员函数。*/
// string getsex();//得到性别
// int getid();//得到学号
// int getmath();//得到数学成绩
// int getchinese();//得到语文成绩
// int getenglish();//得到英语的成绩
// int getofc();//得到c++成绩
// ~StuData();
//};
//class Stulist:public StuData
//{
// private:
// string grade;//班级
// string department;//系别
// public:
// Stulist *next;
// Stulist();//构造函数,对成员进行初始化
// void setgrade();//设置班级
// void add();//添加
// void deletion();//删除
// void change();//修改
// void find();//查找
// void put();//输出
// void subjectsort();//单科成绩排名
// int sum(Stulist *s);//计算总分
// void sumsort();//按总分排序
// int menu();//菜单
// void ADmain();//主控函数
// ~Stulist();//对数据进行相应的处理---链表的销毁自动执行
//};
////----------------------StuData------------------------
//StuData::StuData()
//{
// name="";
// sex="";
// id=0;
// result[0]=0;
// result[1]=0;
// result[2]=0;
// result[3]=0;
//}
//void StuData::get()//输入
//{
// int n,d;
// cout<<"请输入姓名:";
// cin>>name;
// cout<<"请选择性别(1.男 2.女):";
// cin>>n;
// for(;n!=1&&n!=2;)
// {
// cout<<"选择错误,请重新选择(1.男 2.女):";
// cin>>n;
// }
// if(n==1)
// {
// sex="男";
// }
// else
// {
// sex="女";
// }
// cout<<"请输入八位学号:";
// cin>>id;
// for(;n!=8;)
// {
// for(d=id,n=1;d/10!=0;n++)
// {
// d=d/10;
// }
// if(n!=8)
// {
// cout<<"学号必须为八位数字,请重新输入:";
// cin>>id;
// }
// }
// cout<<"请输入数学成绩:";
// cin>>result[0];
// cout<<"请输入语文成绩:";
// cin>>result[1];
// cout<<"请输入英语成绩:";
// cin>>result[2];
// cout<<"请输入c++成绩:";
// cin>>result[3];
//}
//string StuData::getname()
//{
// return name;
//}
//string StuData::getsex()
//{
// return sex;
//}
//int StuData::getid()
//{
// return id;
//}
//int StuData::getmath()
//{
// return result[0];
//}
//int StuData::getchinese()
//{
// return result[1];
//}
//int StuData::getenglish()
//{
// return result[2];
//}
//int StuData::getofc()
//{
// return result[3];
//}
//StuData::~StuData()
//{
//}
////---------------------Stulist------------------------
//Stulist::Stulist()
//{
// grade="";
// department="软件学院";
// next=NULL;
//}
//void Stulist:: setgrade()//设置班级
//{
// int n;
// cout<<"1.网安1 2.网工 3.软件设计 4.数媒 5.云计算"<<endl
// <<"请选择班级:";
// cin>>n;
// for(;n<1||n>5;)
// {
// cout<<" 选择错误,请重新选择(1-5):";
// cin>>n;
// }
// switch(n)
// {
// case 1:grade="网安";break;
// case 2:grade="网工";break;
// case 3:grade="软件设计";break;
// case 4:grade="数媒";break;
// case 5:grade="云计算";break;
// }
//}
//void Stulist::add()//添加学生信息
//{
// Stulist *p=NULL,*pr=NULL,*P=NULL;
// char ch='y';
// pr=this;
// for(;ch=='y';)
// {
// system("cls");
// p=new Stulist;
// p->setgrade();
// p->get();
// P=pr->next;
// pr->next=p;
// p->next=P;
// cout<<"添加成功!"<<endl;
// cout<<"是否继续添加(y/n):";
// cin>>ch;
// ch=tolower(ch);//将字母变为小写
// }
//}
//void Stulist::deletion()//删除
//{
// Stulist *p=NULL,*pr=NULL;
// string str;
// int id,d,n=0;
// char ch='y';
// p=this->next;
// if(p==NULL)
// {
// cout<<"无任何信息!"<<endl;
// system("pause");
// }
// else
// {
// for(;ch=='y';)
// {
// pr=this;
// p=pr->next;
// system("cls");
// cout<<"请输入要删除学生的学号:";
// cin>>id;
// for(;n!=8;)
// {
// for(d=id,n=1;d/10!=0;n++)
// {
// d=d/10;
// }
// if(n!=8)
// {
// cout<<"学号必须为八位数字,请重新输入:";
// cin>>id;
// }
// }
// n=0;
// for(;pr->next!=NULL;)
// {
// if(id==p->getid())
// {
// pr->next=p->next;
// delete(p);
// cout<<"删除成功!"<<endl;
// n=1;
// break;
// }
// else
// {
// pr=pr->next;
// p=pr->next;
// }
// }
// if(n==0)
// {
// cout<<"查无此人!"<<endl;
// }
// getchar();
// cout<<"是否继续删除(y/n):";
// cin>>ch;
// ch=tolower(ch);
// }
// }
//}
//void Stulist::change()//修改
//{
// Stulist *p=NULL,*pr=NULL;
// string str;
// int id,d,n=0;
// char ch='y';
// p=this->next;
// if(p==NULL)
// {
// cout<<"无任何信息!"<<endl;
// system("pause");
// }
// else
// {
// for(;ch=='y';)
// {
// pr=this;
// p=pr->next;
// system("cls");
// cout<<"请输入要修改学生的学号:";
// cin>>id;
// for(;n!=8;)
// {
// for(d=id,n=1;d/10!=0;n++)
// {
// d=d/10;
// }
// if(n!=8)
// {
// cout<<"学号必须为八位数字,请重新输入:";
// cin>>id;
// }
// }
// n=0;
// for(;pr->next!=NULL;)
// {
// if(id==p->getid())
// {
// system("cls");
// cout<<"开始修改";
// p->setgrade();
// p->get();
// cout<<"修改成功!"<<endl;
// n=1;
// break;
// }
// else
// {
// pr=pr->next;
// p=pr->next;
// }
// }
// if(n==0)
// {
// cout<<"查无此人!"<<endl;
// }
// getchar();
// cout<<"是否继续修改(y/n):";
// cin>>ch;
// ch=tolower(ch);
// }
// }
//}
//void Stulist::find()//查找
//{
// Stulist *p=NULL,*pr=NULL;
// string str;
// int id,d,n=0;
// char ch='y';
// p=this->next;
// if(p==NULL)
// {
// cout<<"无任何信息!"<<endl;
// system("pause");
// }
// else
// {
// for(;ch=='y';)
// {
// pr=this;
// p=pr->next;
// system("cls");
// cout<<"请输入要查找学生的学号:";
// cin>>id;
// for(;n!=8;)
// {
// for(d=id,n=1;d/10!=0;n++)
// {
// d=d/10;
// }
// if(n!=8)
// {
// cout<<"学号必须为八位数字,请重新输入:";
// cin>>id;
// }
// }
// n=0;
// for(;pr->next!=NULL;)
// {
// if(id==p->getid())
// {
// system("cls");
// str=p->getname();
// cout<<str<<" ";
// str=p->getsex();
// cout<<str<<" ";
// n=p->getid();
// cout<<n<<" ";
// str=p->grade;
// cout<<str<<" ";
// n=p->getmath();
// cout<<n<<" ";
// n=p->getchinese();
// cout<<n<<" ";
// n=p->getenglish();
// cout<<n<<" ";
// n=p->getofc();
// cout<<n<<endl;
// n=1;
// break;
// }
// else
// {
// pr=pr->next;
// p=pr->next;
// }
// }
// if(n==0)
// {
// cout<<"查无此人!"<<endl;
// }
// getchar();
// cout<<"是否继续查询(y/n):";
// cin>>ch;
// ch=tolower(ch);
// }
// }
//
//
//}
//void Stulist::put()//输出学生信息
//{
// Stulist *p=NULL,*pr=NULL;
// string str;
// int n;
// pr=this;
// p=this->next;
// if(p!=NULL)
// {
// cout<<setw(10)<<"姓名"<<setw(6)<<"性别"<<setw(10)<<"学号"<<setw(10)<<"院系"<<setw(10)<<"班级"
// <<setw(6)<<"数学"<<setw(6)<<"语文"<<setw(6)<<"英语"<<setw(6)<<"c++"<<endl;
// for(;pr->next!=NULL;)
// {
// str=p->getname();
// cout<<setw(10)<<str;
//
// str=p->getsex();
// cout<<setw(6)<<str;
//
// n=p->getid();
// cout<<setw(10)<<n;
//
// str=p->department;
// cout<<setw(10)<<str;
//
// str=p->grade;
// cout<<setw(10)<<str;
//
// n=p->getmath();
// cout<<setw(6)<<n;
//
// n=p->getchinese();
// cout<<setw(6)<<n;
//
// n=p->getenglish();
// cout<<setw(6)<<n;
//
// n=p->getofc();
// cout<<setw(6)<<n<<endl;
// pr=pr->next;
// p=pr->next;
// }
// }
// else
// cout<<"无任何信息!"<<endl;
// system("pause");
//}
//void Stulist::subjectsort()//单科排名
//{
// int n;
// Stulist *p=NULL,*pr=NULL,*tp=NULL,*np=NULL,*wp=NULL;
// p=this->next;
// if(p==NULL)
// {
// cout<<"无任何信息!"<<endl;
// system("pause");
// }
// else
// {
// cout<<"1.数学2.语文 3.英语 4.c++"<<endl
// <<"请选择科目:";
// cin>>n;
// for(;n<1||n>4;)
// {
// cout<<" 选择错误,请重新选择(1-4):";
// cin>>n;
// }
// switch(n)
// {
// case 1:
// for(pr=this;pr->next!=NULL;pr=pr->next)
// {
// for(tp=this,p=this->next;p->next!=NULL;tp=tp->next,p=p->next)
// {
// if(p->getmath()<p->next->getmath())
// {
// np=p->next;
// wp=np->next;
// p->next=wp;
// np->next=p;
// tp->next=np;
// p=np;
// }
// }
// }
// break;
// case 2:
// for(pr=this;pr->next!=NULL;pr=pr->next)
// {
// for(tp=this,p=this->next;p->next!=NULL;tp=tp->next,p=p->next)
// {
// if(p->getchinese()<p->next->getchinese())
// {
// np=p->next;
// wp=np->next;
// p->next=wp;
// np->next=p;
// tp->next=np;
// p=np;
// }
// }
// }
// break;
// case 3:
// for(pr=this;pr->next!=NULL;pr=pr->next)
// {
// for(tp=this,p=this->next;p->next!=NULL;tp=tp->next,p=p->next)
// {
// if(p->getenglish()<p->next->getenglish())
// {
// np=p->next;
// wp=np->next;
// p->next=wp;
// np->next=p;
// tp->next=np;
// p=np;
// }
// }
// }
// break;
// case 4:
// for(pr=this;pr->next!=NULL;pr=pr->next)
// {
// for(tp=this,p=this->next;p->next!=NULL;tp=tp->next,p=p->next)
// {
// if(p->getofc()<p->next->getofc())
// {
// np=p->next;
// wp=np->next;
// p->next=wp;
// np->next=p;
// tp->next=np;
// p=np;
// }
// }
// }
// break;
// }
// put();
// }
//}
//int Stulist::sum(Stulist *s)//计算总分
//{
// return s->getmath() + s->getchinese() + s->getenglish() + s->getofc();
//}
//void Stulist::sumsort()//总分排名
//{
// Stulist *p=NULL,*pr=NULL,*tp=NULL,*np=NULL,*wp=NULL;
// for(pr=this;pr->next!=NULL;pr=pr->next)
// {
// for(tp=this,p=this->next;p->next!=NULL;tp=tp->next,p=p->next)
// {
// if(p->sum(p)<p->sum(p->next))
// {
// np=p->next;
// wp=np->next;
// p->next=wp;
// np->next=p;
// tp->next=np;
// p=np;
// }
// }
// }
// put();
//}
//int Stulist::menu()//菜单
//{
// int n;
// cout<<"\t\t\t\t学生信息管理系统"<<endl
// <<"\t\t\t\t 1.添加"<<endl
// <<"\t\t\t\t 2.删除"<<endl
// <<"\t\t\t\t 3.修改"<<endl
// <<"\t\t\t\t 4.查找"<<endl
// <<"\t\t\t\t 5.输出"<<endl
// <<"\t\t\t\t6.单科成绩排名"<<endl
// <<"\t\t\t\t7.班内总分排名"<<endl
// <<"\t\t\t\t 0.退出"<<endl<<endl<<endl<<endl
// <<"\t\t请选择:";
// cin>>n;
// return n;
//}
//void Stulist::ADmain()//主控
//{
// int n;
// for(;;)
// {
// n=menu();
// switch(n)
// {
// case 1:add();system("cls");break;
// case 2:deletion();system("cls");break;
// case 3:change();system("cls");break;
// case 4:find();system("cls");break;
// case 5:put();system("cls");break;
// case 6:subjectsort();system("cls");break;
// case 7:sumsort();system("cls");break;
// case 0:exit(0);break;
// }
// }
//}
//Stulist::~Stulist()
//{
//}
//void main()
//{
// Stulist a;
// a.ADmain();
//}
#pragma endregion
#pragma region
//#include<iostream>
//using namespace std;
//char fun(char *s)
//{
//
//}
//int main()
//{
// char *a = "abcdef";
// printf("%d\n",fun(a));
// /*int a;
// scanf("%d",&a);
// printf("%s",(a%2! = 0)? "No":"Yes");*/
// return 0;
//}
#pragma endregion
#pragma region
//#include<stdio.h>
//int main (void)
//{
// int year, month, day, sum=0,leap;
// scanf("%d %d %d\n",&year,&month,&day);
// switch(month)
// {
//case1:
// sum=0;
// break;
//case2:
// sum=31;
// break;
//case3:
// sum=59;
// break;
//case4:
// sum=90;
// break;
//case5:
// sum=120;
// break;
//case6:
// sum=151;
// break;
//case7:
// sum=181;
// break;
//case8:
// sum=212;
// break;
//case9:
// sum=243;
// break;
//case10:
// sum=273;
// break;
//case11:
// sum=304;
// break;
//case12:
// sum=334;
// break;
// }
// sum=sum+day;
// if(year%4==0)
// leap=1;
// else
// leap=0;
// if(leap==1&&month>2)
// sum=sum++;
// printf("%d\n",sum);
// return 0;
//}
#pragma endregion
#include "stdio.h"
int main()
{
int c[10],*p,min,max,m,n,t;
printf("请输入十个整数:\n");
for(p=c;p-c<10;p++)
scanf("%d",p);
p=c;
max=min=*p; //改动一下就可以啦,,本来是逗号表达式 ,,,具体细节自己调试吧,,其实多算一个数
for(p=p+1;p-c<10;p++)
{
if(max<*p) {max=*p;m=p-c;}
if(min>*p) {min=*p;n=p-c;}
}
p=c;t=*p;*p=*(p+n);*(p+n)=t;
t=*(p+9);*(p+9)=*(p+m);*(p+m)=t;
printf("对换后的十个数为:\n");
for(p=c;p-c<10;p++)
printf("%d ",*p);
printf("\n");
getchar();
return 0;
}
编译环境 vs2010 debug 模式