Codeforces Beta Round #85 (Div. 2 Only) A : Petya and Strings

問題概要

文字列が二つ与えられるので大文字小文字を無視してstrcmpした結果を出力する問題。

acceptされたコード

計算量O(strlen)。

#include <cstdio>
#include <cstring>
#include <cctype>
using namespace std;

const int MAX_L = 100;

char buf[2][MAX_L + 1];

int main(){

	for(int i=0; i<2; i++){
		scanf("%[^\n]%*c", buf[i]);
		for(int j=0; buf[i][j]; j++){
			buf[i][j] = tolower(buf[i][j]);
		}
	}

	printf("%d\n", strcmp(buf[0], buf[1]));

	return 0;
}