Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Help! presentation error

Posted by Cherles at 2013-10-26 13:21:54 on Problem 1007
C code:
/*
 ============================================================================
 Name        : poj1007.c
 Author      : Cherles
 Version     :
 Copyright   : Your copyright notice
 Description : Hello World in C, Ansi-style
 ============================================================================
 */

#include <stdio.h>
#include <stdlib.h>
#define MAX_NUM 1000
#define MAXLENGHT 100
int main(void) {
	int i, j, k, number = 0, len = 0;
	char input[MAX_NUM][MAXLENGHT];
	int value[MAX_NUM];
	scanf("%d%d", &len, &number);

	for (i = 0; i < number; i++) {
		for (j = 0; j <= len; j++) {
			input[i][j] = getchar();
			value[i] = 0;
		}
	}
	for (i = 0; i < number; i++) {
		for (j = 0; j <= len - 1; j++) {
			for (k = j + 1; k <= len; k++) {
				if (input[i][j] > input[i][k]) {
					value[i]++;
				}
			}
		}
	}

	for (i = 0; i < number; i++) {
		for (j = i + 1; j < number; j++) {
			if (value[i] > value[j]) {
				int temp = 0;
				char tempstr[MAXLENGHT];
				temp = value[i];
				value[i] = value[j];
				value[j] = temp;
				for (k = 0; k <=len; k++) {
					tempstr[k] = input[i][k];
					input[i][k] = input[j][k];
					input[j][k] = tempstr[k];
				}
			}
		}
	}
	for (i = 0; i < number; i++) {
		for (j = 0; j <= len; j++) {
			putchar(input[i][j]);
		}
	}

	return EXIT_SUCCESS;
}


Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator