| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
为什么会错的?有谁帮我看一下吗?谢谢。/*
* File: POJ-1804-bubble.cpp
* Author: james
*
* Created on 23 January 2009, 15:57
*/
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cctype>
#include <iostream>
#include <vector>
#include <utility>
#include <set>
#include <map>
#include <string>
#include <complex>
#include <functional>
#include <algorithm>
#include <sstream>
#include <bitset>
#include <fstream>
using namespace std;
int stage[1001];
int main() {
int n;
int cas = 1;
while (scanf("%d", &n) != EOF) {
while (n--) {
int t;
scanf("%d", &t);
for (int i = 0; i < t; i++)
scanf("%d", &stage[i]);
int res = 0;
for (int i = 0; i < t; i++) {
for (int j = 0; j < t - i - 1; j++)
if (stage[j] > stage[j + 1]) {
swap(stage[j], stage[j + 1]);
res++;
}
}
printf("Scenario #%d:\n%d\n\n", cas++, res);
}
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator