2014年2月18日 星期二

UVA 10327 C++

http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1268

#include<iostream>
using namespace std;

int main()
{
int *data;
int N = 0,count=0;
while (cin >> N)
{
data = new int[N];
count = 0;
for (int i = 0; i <= N - 1; i++)
cin >> data[i];
for (int j = 0; j <= N - 2;j++)
for (int k = j + 1; k <= N-1;k++)
if (data[k] < data[j])
count++;
delete data;
cout << "Minimum exchange operations : " << count << endl;
}
return 0;
}

沒有留言:

張貼留言