Chinaunix首页 | 论坛 | 博客
  • 博客访问: 126983
  • 博文数量: 22
  • 博客积分: 1126
  • 博客等级: 少尉
  • 技术积分: 282
  • 用 户 组: 普通用户
  • 注册时间: 2010-10-22 23:01
个人简介

勇敢追求自己,加油加油

文章分类

全部博文(22)

文章存档

2011年(1)

2010年(21)

我的朋友

分类: C/C++

2010-12-01 20:11:03

//***********************************************

#include

using namespace std;
#include
struct student
{
int num;
char name[10];
float score[3];
float avg_score;
student *next;
}stu[100],*p;
void print(student *p)
{
cout<<"学生"<name<<" 的学号为:"<num;
p->avg_score=(p->score[0]+p->score[2]+p->score[3])/3;
cout<<"语文分数为:"<score[0]<<
"数学分数为:"<score[1]<<"英语分数为:"<<
p->score[2]<<"平均分数为:"<avg_score<}
int main()
{
int stu_num;
int i;
cout<<"请输入学生数目:";
cin>>stu_num;
for(i=0;i {
cout<<"请输入学生"< cin>>stu[i].num;
//********************
cout<<"姓名:";
cin>>stu[i].name;
//********************
cout<<"语文分数:";
cin>>stu[i].score[0];
//********************
cout<<"数学分数为:";
cin>>stu[i].score[1];
//********************
cout<<"英语分数为:";
cin>>stu[i].score[2];
cout< }
for(i=0;i {
stu[i].next=&stu[i+1];
}
stu[stu_num-1].next=NULL;
p=&stu[0];
do{
print(p);
p=p->next;
}while(p!=NULL);
return 0;

}

//******************************************

#include
using namespace std;
union variant
{
int ival;
float fval;
double dval;
};
union variant s={5};
int main()
{
union variant *p=&s;
cout<<"s.ival= "< cout<<"p->fval= "<fval< cout<<"(*p).dval= "<<(*p).dval< return 0;
}
//******************************************

#include
using namespace std;
union variant
{
int ival;
float fval;
double dval;
};
union variant s1={5};
int main()
{
union variant *p=&s1;
union variant s2;
s2=s1;
cout<<"p->ival= "<ival< cout<<"s2.ival= "< return 0;
}
//*******************************************

#include
using namespace std;
#include
struct test
{
char name[10];
float score;
};
void print_score(test &pn)
{
cout<}
int main()
{
test a[2]={{"张三",88.5f},{"li_si",98.6F}};
int num=sizeof(a)/sizeof(test);
for(int i=0;i {
print_score(a[i]);
}
return 0;
}
//***********************************************


#include
using namespace std;
enum Direction1 {up1,down1,back1,left1,right1};
enum Direction2 {up2=7,down2=2,back2,left2,right2};
int main()
{
cout<<"Direction1.up1= "< cout<<"Direction1.down1= "< cout<<"Direction1.back1= "< cout<<"Direction1.left1= "< cout<<"Direction1.right1= "< //*********************************
cout<<"Direction2.up2= "< cout<<"Direction2.down2= "< cout<<"Direction2.back2= "< cout<<"Direction2.left2= "< cout<<"Direction2.right2= "< return 0;
}

//******************************************

#include
using namespace std;
int main()
{
enum Direction1{up1,down1,before1,back1,left1,right1};
enum Direction1 first;
cout<<"first Direction is defined"< enum Direction2{up2,down2,before2,back2,left2,right2} second;
cout<<"second Direction is defined"< return 0;
}
//********************************************

#include
using namespace std;
int main()
{
int i=1;
cout<<"i="< return 0;
}
//*****************************************

#include
using namespace std;
typedef int COUNT;
typedef double AREA;
typedef struct
{
double x;
double y;
double z;
}Point;
typedef char * STRING;
int main()
{
COUNT a=100;
cout<<"a= "< AREA b=50.02;
cout<<"b= "< Point op={1.0,2.0,3.0};
cout<<"op.x= "< op.y<<"\t"< STRING csName={"John"};
cout<<"csName= "< return 0;
}
//****************************************

#include
using namespace std;
struct bs
{
unsigned a:1;
unsigned b:3;
unsigned c:4;
}bit,*pbit;
int main()
{
bit.a=1;
bit.b=7;
bit.c=15;
cout<<"bit.a= "< "\t"<<"bit.b= "< "\t"<<"bit.c= "< endl;
pbit=&bit;
pbit->a=0;
pbit->b&=3;
pbit->c|=1;
cout< <<"\t"<<"bit.b= "< "\t"<<"bit.c= "< return 0;
}
//************************************

#include
using namespace std;
enum COLORS
{
BLACK,BLUE,GREEN,CYAN,RED,MAGENTA,BROWN,
LITHTGRAY,DARKGRAY,LIGHTBLUE,LIGHTGREEN,
LIGHTCYAN,LIGHTRED,LIGHTMAGENTA,YELLOW,
WHITE};
int main()
{
enum COLORS a,b,c;
enum COLORS *pa;
int d=2;
a=RED;
b=WHITE;
c=BLACK;
cout<<"a= "< cout<<"b= "< cout<<"c= "< cout<<"d= "< int e=a+b;
if(a>b)
pa=&a;
else
pa=&b;
cout<<"*pa= "<<*pa< cout<<"e= "< return 0;
}
//**********************************************

阅读(966) | 评论(2) | 转发(0) |
给主人留下些什么吧!~~

chinaunix网友2010-12-29 20:36:08

很好的, 收藏了 推荐一个博客,提供很多免费软件编程电子书下载: http://free-ebooks.appspot.com

chinaunix网友2010-12-29 20:35:54

很好的, 收藏了 推荐一个博客,提供很多免费软件编程电子书下载: http://free-ebooks.appspot.com