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 |
高手帮看看程序啊 为什么错啊#include <stdio.h> #include <stdlib.h> int i,j,tt,n; float mid,s[1000],ss[1000]; int c[1001][1001]; void len()// 推出最大子序列 { for (i=1;i<=n ;i++) c[i][0]=0; for (j=1;j<=n;j++) c[0][j]=0; for (i=1;i<=n;i++) for (j=1;j<=n;j++) { if (s[i-1]==ss[j-1]) {c[i][j]=c[i-1][j-1]+1;} else if (c[i-1][j]>=c[i][j-1]) c[i][j]=c[i-1][j]; else c[i][j]=c[i][j-1]; } return; } int main(int argc, char *argv[]) { scanf("%d",&n); for (i=0;i<n;i++) {scanf("%f",&s[i]); ss[i]=s[i]; } for (i=0;i<n-1;i++)//排序 for (j=i+1;j<n;j++) { if (ss[i]>ss[j]) {mid=ss[j];ss[j]=ss[i];ss[i]=mid;}} len ();//求原数列和排序后序列的最大子序列 tt=c[n][n]; for (i=0;i<=((n-1)/2);i++)//转置排序序列 {mid=ss[i];ss[i]=ss[n-i-1];ss[n-i-1]=mid;}; len(); if (tt<c[n][n]) tt=c[n][n]; printf("%d",n-tt); //system("PAUSE"); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator