tianxuyuan

置顶随笔 #

[置顶]自学class 可是做半天的题目 电脑上数据答案对了 提交是不对的 〔内附题目 我的答案〕

怎么这样这样?
下面是提交后的显示:
编译失败...|错误号:1

MyProger\Prog69647.cpp:24: error: expected `;' before '(' token
MyProger\Prog69647.cpp:27: error: expected `;' before "int"
MyProger\Prog69647.cpp: In function `int main()':
MyProger\Prog69647.cpp:59: error: 'class Student' has no member named 'add'

高手们大侠们救命阿!
//=====================
#include<iostream>
#include<iomanip>
using namespace std;
//---------------------------------------------
class Student{
 string name;
  int mark;
   int classmark;
    char isganbu;
    char isxibu;
    int lw;
    int jxj;
public :
 void set(string na, int ma, int cl, char isga,char isxi,int l, int jx){
   name=na;mark=ma;classmark=cl;isganbu=isga;isxibu=isxi;lw=l;jxj=jx;
  }
 bool isys();
 bool isws();
 bool iscj();
 bool isxb();
 bool isbj();

 void  sumjxj(){
  if(isys()) jxj+=8000;
  if(isws()) jxj+=4000;
  if(iscj()) jxj+=2000;
  if(isxb()) jxj+=1000;
  if(isbj()) jxj+= 850;
  }
 int add(& sum){
  sum=sum+jxj ;
 }
 int  mmax(string & name1,int & jxj1){
  if(jxj>jxj1){ name1=name;jxj1=jxj ;}
    }
};
//-------------------------------------
 bool Student::isys(){
  return (mark>80&&lw>0);
  }
  bool Student::isws(){
   return (mark>85&&classmark>80 );
  }
  bool Student::iscj(){
   return (mark>90);
   }
  bool Student::isxb(){
   return (mark>85&&isxibu=='Y');
   }
  bool Student::isbj(){
   return (classmark>80&&isganbu=='Y');
   }
//---------------------------------------
int main(){
 string name1=" "; int jxj1=0; int sum=0;
 int n; cin>>n;
 for(;n;n--){
  Student x;
  string na; int ma; int cl; char isga;char isxi;int l; int jx=0;
  cin>>na>>ma>>cl>>isga>>isxi>>l;
  //jx=0;
  x.set(na,ma,cl,isga,isxi,l,jx);
  x.sumjxj();

  x.add(sum);
  x.mmax(name1,jxj1);

  }
 cout<<name1<<'\n';
 cout<<jxj1<<'\n';
 cout<<sum<<'\n';
  }

描述 Description
    某校的惯例是在每学期的期末考试之后发放奖学金。发放的奖学金共有五种,获取的条件各自不同:

  1)  院士奖学金,每人8000元,期末平均成绩高于80分(>80),并且在本学期内发表1篇或1篇以上论文的学生均可获得;

  2)  五四奖学金,每人4000元,期末平均成绩高于85分(>85),并且班级评议成绩高于80分(>80)的学生均可获得;

  3)  成绩优秀奖,每人2000元,期末平均成绩高于90分(>90)的学生均可获得;

  4)  西部奖学金,每人1000元,期末平均成绩高于85分(>85)的西部省份学生均可获得;

  5)  班级贡献奖,每人850元,班级评议成绩高于80分(>80)的学生干部均可获得;

  只要符合条件就可以得奖,每项奖学金的获奖人数没有限制,每名学生也可以同时获得多项奖学金。例如姚林的期末平均成绩是87分,班级评议成绩82分,同时他还是一位学生干部,那么他可以同时获得五四奖学金和班级贡献奖,奖金总数是4850元。

  现在给出若干学生的相关数据,请计算哪些同学获得的奖金总数最高(假设总有同学能满足获得奖学金的条件)。
输入格式 Input Format
    输入的第一行是一个整数N(1 <= N <= 100),表示学生的总数。接下来的N行每行是一位学生的数据,从左向右依次是姓名,期末平均成绩,班级评议成绩,是否是学生干部,是否是西部省份学生,以及发表的论文数。姓名是由大小写英文字母组成的长度不超过20的字符串(不含空格);期末平均成绩和班级评议成绩都是0到100之间的整数(包括0和100);是否是学生干部和是否是西部省份学生分别用一个字符表示,Y表示是,N表示不是;发表的论文数是0到10的整数(包括0和10)。每两个相邻数据项之间用一个空格分隔。
输出格式 Output Format
    输出包括三行,第一行是获得最多奖金的学生的姓名,第二行是这名学生获得的奖金总数。如果有两位或两位以上的学生获得的奖金最多,输出他们之中在输入文件中出现最早的学生的姓名。第三行是这N个学生获得的奖学金的总数。

in
4
YaoLin 87 82 Y N 0
ChenRuiyi 88 78 N Y 1
LiXin 92 88 N N 0
ZhangQin 83 87 Y N 1
out
ChenRuiyi
9000
28700

posted @ 2007-08-16 23:01 田旭园 阅读(651) | 评论 (5)编辑 收藏

[置顶]放假在家 学习类 今天编了日期简单处理的

//===========================
#include<iostream>
#include<iomanip>
//========================
using namespace std;
class Date{
 int year,month,day;
public:
 bool isleapyear(){
   return(year%4==0&&year%100!=0)||(year%400==0);
   }
 void print(){
  cout<<setfill('0');
  cout<<setw(4)<<year<<'-'<<setw(2)<<month<<'-'<<setw(2)<<day<<'\n';
  cout<<setfill(' ');
  }
  void set(int y,int m,int d){
   year=y;  month=m; day=d;
  }
 };
//--------------------------
int main(){
 Date kk;
 int n;cin>>n;
 for(int i=1;i<=n;i++){
    int y;int m;int d;
     cin>>y>>m>>d;                                   //  kk.set(1000,8,16);
     kk.set(y,m,d);
    if(kk.isleapyear()) kk.print();
     else cout<<"notleap\n";
  }
 cout<<"over"<<'\n';
}
//--------------------------

想用类做8个排序算法 有点没有头绪阿

posted @ 2007-08-16 11:15 田旭园 阅读(305) | 评论 (1)编辑 收藏

[置顶]待做

Sorting by Swapping
Time Limit:1000MS  Memory Limit:10000K
Total Submit:2515 Accepted:1374

Description
Given a permutation of numbers from 1 to n, we can always get the sequence 1, 2, 3, ..., n by swapping pairs of numbers. For example, if the initial sequence is 2, 3, 5, 4, 1, we can sort them in the following way:

2 3 5 4 1
1 3 5 4 2
1 3 2 4 5
1 2 3 4 5

Here three swaps have been used. The problem is, given a specific permutation, how many swaps we needs to take at least.


Input
The first line contains a single integer t (1 <= t <= 20) that indicates the number of test cases. Then follow the t cases. Each case contains two lines. The first line contains the integer n (1 <= n <= 10000), and the second line gives the initial permutation.

Output
For each test case, the output will be only one integer, which is the least number of swaps needed to get the sequence 1, 2, 3, ..., n from the initial permutation.

Sample Input


2
3
1 2 3
5
2 3 5 4 1

Sample Output


0
3

posted @ 2007-05-05 11:17 田旭园 阅读(559) | 评论 (1)编辑 收藏

2007年8月16日 #

自学class 可是做半天的题目 电脑上数据答案对了 提交是不对的 〔内附题目 我的答案〕

怎么这样这样?
下面是提交后的显示:
编译失败...|错误号:1

MyProger\Prog69647.cpp:24: error: expected `;' before '(' token
MyProger\Prog69647.cpp:27: error: expected `;' before "int"
MyProger\Prog69647.cpp: In function `int main()':
MyProger\Prog69647.cpp:59: error: 'class Student' has no member named 'add'

高手们大侠们救命阿!
//=====================
#include<iostream>
#include<iomanip>
using namespace std;
//---------------------------------------------
class Student{
 string name;
  int mark;
   int classmark;
    char isganbu;
    char isxibu;
    int lw;
    int jxj;
public :
 void set(string na, int ma, int cl, char isga,char isxi,int l, int jx){
   name=na;mark=ma;classmark=cl;isganbu=isga;isxibu=isxi;lw=l;jxj=jx;
  }
 bool isys();
 bool isws();
 bool iscj();
 bool isxb();
 bool isbj();

 void  sumjxj(){
  if(isys()) jxj+=8000;
  if(isws()) jxj+=4000;
  if(iscj()) jxj+=2000;
  if(isxb()) jxj+=1000;
  if(isbj()) jxj+= 850;
  }
 int add(& sum){
  sum=sum+jxj ;
 }
 int  mmax(string & name1,int & jxj1){
  if(jxj>jxj1){ name1=name;jxj1=jxj ;}
    }
};
//-------------------------------------
 bool Student::isys(){
  return (mark>80&&lw>0);
  }
  bool Student::isws(){
   return (mark>85&&classmark>80 );
  }
  bool Student::iscj(){
   return (mark>90);
   }
  bool Student::isxb(){
   return (mark>85&&isxibu=='Y');
   }
  bool Student::isbj(){
   return (classmark>80&&isganbu=='Y');
   }
//---------------------------------------
int main(){
 string name1=" "; int jxj1=0; int sum=0;
 int n; cin>>n;
 for(;n;n--){
  Student x;
  string na; int ma; int cl; char isga;char isxi;int l; int jx=0;
  cin>>na>>ma>>cl>>isga>>isxi>>l;
  //jx=0;
  x.set(na,ma,cl,isga,isxi,l,jx);
  x.sumjxj();

  x.add(sum);
  x.mmax(name1,jxj1);

  }
 cout<<name1<<'\n';
 cout<<jxj1<<'\n';
 cout<<sum<<'\n';
  }

描述 Description
    某校的惯例是在每学期的期末考试之后发放奖学金。发放的奖学金共有五种,获取的条件各自不同:

  1)  院士奖学金,每人8000元,期末平均成绩高于80分(>80),并且在本学期内发表1篇或1篇以上论文的学生均可获得;

  2)  五四奖学金,每人4000元,期末平均成绩高于85分(>85),并且班级评议成绩高于80分(>80)的学生均可获得;

  3)  成绩优秀奖,每人2000元,期末平均成绩高于90分(>90)的学生均可获得;

  4)  西部奖学金,每人1000元,期末平均成绩高于85分(>85)的西部省份学生均可获得;

  5)  班级贡献奖,每人850元,班级评议成绩高于80分(>80)的学生干部均可获得;

  只要符合条件就可以得奖,每项奖学金的获奖人数没有限制,每名学生也可以同时获得多项奖学金。例如姚林的期末平均成绩是87分,班级评议成绩82分,同时他还是一位学生干部,那么他可以同时获得五四奖学金和班级贡献奖,奖金总数是4850元。

  现在给出若干学生的相关数据,请计算哪些同学获得的奖金总数最高(假设总有同学能满足获得奖学金的条件)。
输入格式 Input Format
    输入的第一行是一个整数N(1 <= N <= 100),表示学生的总数。接下来的N行每行是一位学生的数据,从左向右依次是姓名,期末平均成绩,班级评议成绩,是否是学生干部,是否是西部省份学生,以及发表的论文数。姓名是由大小写英文字母组成的长度不超过20的字符串(不含空格);期末平均成绩和班级评议成绩都是0到100之间的整数(包括0和100);是否是学生干部和是否是西部省份学生分别用一个字符表示,Y表示是,N表示不是;发表的论文数是0到10的整数(包括0和10)。每两个相邻数据项之间用一个空格分隔。
输出格式 Output Format
    输出包括三行,第一行是获得最多奖金的学生的姓名,第二行是这名学生获得的奖金总数。如果有两位或两位以上的学生获得的奖金最多,输出他们之中在输入文件中出现最早的学生的姓名。第三行是这N个学生获得的奖学金的总数。

in
4
YaoLin 87 82 Y N 0
ChenRuiyi 88 78 N Y 1
LiXin 92 88 N N 0
ZhangQin 83 87 Y N 1
out
ChenRuiyi
9000
28700

posted @ 2007-08-16 23:01 田旭园 阅读(651) | 评论 (5)编辑 收藏

放假在家 学习类 今天编了日期简单处理的

//===========================
#include<iostream>
#include<iomanip>
//========================
using namespace std;
class Date{
 int year,month,day;
public:
 bool isleapyear(){
   return(year%4==0&&year%100!=0)||(year%400==0);
   }
 void print(){
  cout<<setfill('0');
  cout<<setw(4)<<year<<'-'<<setw(2)<<month<<'-'<<setw(2)<<day<<'\n';
  cout<<setfill(' ');
  }
  void set(int y,int m,int d){
   year=y;  month=m; day=d;
  }
 };
//--------------------------
int main(){
 Date kk;
 int n;cin>>n;
 for(int i=1;i<=n;i++){
    int y;int m;int d;
     cin>>y>>m>>d;                                   //  kk.set(1000,8,16);
     kk.set(y,m,d);
    if(kk.isleapyear()) kk.print();
     else cout<<"notleap\n";
  }
 cout<<"over"<<'\n';
}
//--------------------------

想用类做8个排序算法 有点没有头绪阿

posted @ 2007-08-16 11:15 田旭园 阅读(305) | 评论 (1)编辑 收藏

2007年5月22日 #

刚作好的 叫DNA 想用取余的做可是做不出来 高人帮忙~~

Input:

输入包含多组测试数据。第一个整数N(N<=15),N表示组数,每组数据包含两个整数a,b。a表示一个单位的DNA串的行数,a为奇数且 3<=a<=39。b表示重复度(1<=b<=20)。

Output:

输出DNA的形状,每组输出间有一空行。

Sample Input:

2
3 1
5 4

Sample Output:

X X
X
X X
X   X
X X
X
X X
X   X
X X
X
X X
X   X
X X
X
X X
X   X
X X
X
X X
X   X



#include<iostream>
#include<string>
using namespace std;
int main()
{

int n; cin>>n;
int m=1;
for(int a,b;n&&cin>>a>>b;n--)
{ cout<<(m==1?"":"\n");

 for(int i=1;i<=b;i++)
  {for(int j=1;j<=a/2;j++)
  {
   cout<<string(j-1,' ');
   cout<<'X';
   cout<<string(a-2*(j-1)-2,' ');
   cout<<'X'<<'\n';
   }
    cout<<string(a/2,' ');
    cout<<'X'<<'\n';
    for(int i=a/2;i>1;i--)
    { cout<<string(i-1,' ');
      cout<<'X';
   cout<<string(a-2*(i-1)-2,' ');
   cout<<'X'<<'\n';
   }
   }
  cout<<'X';cout<<string(a-2,' ');
  cout<<'X'<<'\n';


  m++;
  }

  }

posted @ 2007-05-22 18:30 田旭园 阅读(450) | 评论 (0)编辑 收藏

2007年5月6日 #

I wish

#include<stdio.h>
void main()
{
  int day;
  for(day=1;day<=365;day++)
      printf("I wish you happy everyday!\n");
}

posted @ 2007-05-06 14:26 田旭园 阅读(609) | 评论 (2)编辑 收藏

2007年5月5日 #

StrInt + - * /(整除) % (取模)

/ StrInt + - * /(整除) % (取模)
//=====================================
#ifndef STRINT_HEADER
#define STRINT_HEADER
#include<iostream>
using namespace std;
//-------------------------------------
class StrInt{
  enum { BYTENUM = 200 };
  string _sign;
  string _num;
public:
  StrInt(const string& a = string("0") );
  StrInt(const string& sign, const string& num);
  friend StrInt mul( const StrInt& a, const StrInt& b );
  friend StrInt add( const StrInt& a, const StrInt& b );
  friend StrInt sub( const StrInt& a, const StrInt& b );
  friend StrInt div( const StrInt& a, const StrInt& b );
  friend StrInt mod( const StrInt& a, const StrInt& b );
  friend istream& operator>>(istream& in, StrInt& a);
  friend ostream& operator<<(ostream& out, const StrInt& a);
};//-----------------------------------
#endif   // STRINT_HEADER

posted @ 2007-05-05 11:20 田旭园 阅读(1511) | 评论 (0)编辑 收藏

待做

Sorting by Swapping
Time Limit:1000MS  Memory Limit:10000K
Total Submit:2515 Accepted:1374

Description
Given a permutation of numbers from 1 to n, we can always get the sequence 1, 2, 3, ..., n by swapping pairs of numbers. For example, if the initial sequence is 2, 3, 5, 4, 1, we can sort them in the following way:

2 3 5 4 1
1 3 5 4 2
1 3 2 4 5
1 2 3 4 5

Here three swaps have been used. The problem is, given a specific permutation, how many swaps we needs to take at least.


Input
The first line contains a single integer t (1 <= t <= 20) that indicates the number of test cases. Then follow the t cases. Each case contains two lines. The first line contains the integer n (1 <= n <= 10000), and the second line gives the initial permutation.

Output
For each test case, the output will be only one integer, which is the least number of swaps needed to get the sequence 1, 2, 3, ..., n from the initial permutation.

Sample Input


2
3
1 2 3
5
2 3 5 4 1

Sample Output


0
3

posted @ 2007-05-05 11:17 田旭园 阅读(559) | 评论 (1)编辑 收藏

仅列出标题