锘??xml version="1.0" encoding="utf-8" standalone="yes"?>
緙栬瘧澶辮觸...|閿欒鍙?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綃囦互涓婅鏂囩殑瀛︾敓鍧囧彲鑾峰緱錛?br> 銆銆2) 浜斿洓濂栧閲戯紝姣忎漢4000鍏冿紝鏈熸湯騫沖潎鎴愮嘩楂樹簬85鍒嗭紙>85錛夛紝騫朵笖鐝駭璇勮鎴愮嘩楂樹簬80鍒嗭紙>80錛夌殑瀛︾敓鍧囧彲鑾峰緱錛?br> 銆銆3) 鎴愮嘩浼樼濂栵紝姣忎漢2000鍏冿紝鏈熸湯騫沖潎鎴愮嘩楂樹簬90鍒嗭紙>90錛夌殑瀛︾敓鍧囧彲鑾峰緱錛?br> 銆銆4) 瑗塊儴濂栧閲戯紝姣忎漢1000鍏冿紝鏈熸湯騫沖潎鎴愮嘩楂樹簬85鍒嗭紙>85錛夌殑瑗塊儴鐪佷喚瀛︾敓鍧囧彲鑾峰緱錛?br> 銆銆5) 鐝駭璐$尞濂栵紝姣忎漢850鍏冿紝鐝駭璇勮鎴愮嘩楂樹簬80鍒嗭紙>80錛夌殑瀛︾敓騫查儴鍧囧彲鑾峰緱錛?br> 銆銆鍙絎﹀悎鏉′歡灝卞彲浠ュ緱濂栵紝姣忛」濂栧閲戠殑鑾峰浜烘暟娌℃湁闄愬埗錛屾瘡鍚嶅鐢熶篃鍙互鍚屾椂鑾峰緱澶氶」濂栧閲戙備緥濡傚鏋楃殑鏈熸湯騫沖潎鎴愮嘩鏄?7鍒嗭紝鐝駭璇勮鎴愮嘩82鍒嗭紝鍚屾椂浠栬繕鏄竴浣嶅鐢熷共閮紝閭d箞浠栧彲浠ュ悓鏃惰幏寰椾簲鍥涘瀛﹂噾鍜岀彮綰ц礎鐚錛屽閲戞繪暟鏄?850鍏冦?br> 銆銆鐜板湪緇欏嚭鑻ュ共瀛︾敓鐨勭浉鍏蟲暟鎹紝璇瘋綆楀摢浜涘悓瀛﹁幏寰楃殑濂栭噾鎬繪暟鏈楂橈紙鍋囪鎬繪湁鍚屽鑳芥弧瓚寵幏寰楀瀛﹂噾鐨勬潯浠訛級銆?br> |
|||
杈撳叆鏍煎紡 Input Format | |||
銆銆杈撳叆鐨勭涓琛屾槸涓涓暣鏁癗錛? <= N <= 100錛夛紝琛ㄧず瀛︾敓鐨勬繪暟銆傛帴涓嬫潵鐨凬琛屾瘡琛屾槸涓浣嶅鐢熺殑鏁版嵁錛屼粠宸﹀悜鍙充緷嬈℃槸濮撳悕錛屾湡鏈鉤鍧囨垚緇╋紝鐝駭璇勮鎴愮嘩錛屾槸鍚︽槸瀛︾敓騫查儴錛屾槸鍚︽槸瑗塊儴鐪佷喚瀛︾敓錛屼互鍙婂彂琛ㄧ殑璁烘枃鏁般傚鍚嶆槸鐢卞ぇ灝忓啓鑻辨枃瀛楁瘝緇勬垚鐨勯暱搴︿笉瓚呰繃20鐨勫瓧絎︿覆錛堜笉鍚┖鏍鹼級錛涙湡鏈鉤鍧囨垚緇╁拰鐝駭璇勮鎴愮嘩閮芥槸0鍒?00涔嬮棿鐨勬暣鏁幫紙鍖呮嫭0鍜?00錛夛紱鏄惁鏄鐢熷共閮ㄥ拰鏄惁鏄タ閮ㄧ渷浠藉鐢熷垎鍒敤涓涓瓧絎﹁〃紺猴紝Y琛ㄧず鏄紝N琛ㄧず涓嶆槸錛涘彂琛ㄧ殑璁烘枃鏁版槸0鍒?0鐨勬暣鏁幫紙鍖呮嫭0鍜?0錛夈傛瘡涓や釜鐩擱偦鏁版嵁欏逛箣闂寸敤涓涓┖鏍煎垎闅斻?br> | |||
杈撳嚭鏍煎紡 Output Format | |||
銆銆杈撳嚭鍖呮嫭涓夎錛岀涓琛屾槸鑾峰緱鏈澶氬閲戠殑瀛︾敓鐨勫鍚嶏紝絎簩琛屾槸榪欏悕瀛︾敓鑾峰緱鐨勫閲戞繪暟銆傚鏋滄湁涓や綅鎴栦袱浣嶄互涓婄殑瀛︾敓鑾峰緱鐨勫閲戞渶澶氾紝杈撳嚭浠栦滑涔嬩腑鍦ㄨ緭鍏ユ枃浠朵腑鍑虹幇鏈鏃╃殑瀛︾敓鐨勫鍚嶃傜涓夎鏄繖N涓鐢熻幏寰楃殑濂栧閲戠殑鎬繪暟銆?br> |
杈撳叆鍖呭惈澶氱粍嫻嬭瘯鏁版嵁銆傜涓涓暣鏁癗錛圢<=15錛?N琛ㄧず緇勬暟錛屾瘡緇勬暟鎹寘鍚袱涓暣鏁癮,b銆俛琛ㄧず涓涓崟浣嶇殑DNA涓茬殑琛屾暟錛宎涓哄鏁頒笖 3<=a<=39銆俠琛ㄧず閲嶅搴?1<=b<=20)銆?
杈撳嚭DNA鐨勫艦鐘訛紝姣忕粍杈撳嚭闂存湁涓絀鴻銆?
2 3 1 5 4
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++;
}
}
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