2016/07/11

[ACM] Q10008

#include 
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <algorithm>

struct item{
 char chr;
 int time;
};

using namespace std;

int main(){

 int n;
 item data[26];
 char str[1024]="", line[256];
 
 for(int i=0; i<26; i++){ 
  data[i].chr = 'A'+i;
  data[i].time=0;
 }
 
 scanf("%d", &n);
 getchar();
 
 while(n){
  gets(line);
  strcat(str, line);
  n--;
 }
 
 for(int i=0; i<strlen(str); i++){
  
  if(isalpha(str[i])){
   
   if(isupper(str[i])){
    //upper letter
    data[str[i]-'A'].time++;
    
   }else{
    //lower letter
    data[str[i]-'a'].time++;
   }
  }
  
 }
 
 //sort
 for(int i=0; i<26; i++){
  
  for(int j=i+1; j<26; j++){
   
   if(data[j].time > data[i].time){
    swap(data[i], data[j]);
    
   }else if(data[i].time == data[j].time){
    
    if(toupper(data[i].chr) > toupper(data[j].chr)){
     swap(data[i], data[j]);
    }
   }
  }
 }
 
 //display result
 for(int i=0; i<26; i++){
  if(data[i].time > 0){
   printf("%c %d\n", data[i].chr, data[i].time);
  }
 }
 
 return 0;

2016/07/05

[Python] PyPI (Python Package)

https://pypi.python.org/pypi

[Python] pip.py path in Windows

If you get the error message "pip is not recognized as an internal or external command,
operable program or batch file."  Add the path below to environment variable:

C:\Users\User_Name\AppData\Local\Programs\Python\Python35-32\Scripts