Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Algorithm Study/2014/Hard Disk Drive: Difference between revisions

From ZeroWiki
imported>ccang8
No edit summary
 
imported>ccang8
No edit summary
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&category=595&page=show_problem&problem=4553
권준혁 소스코드


  #pragma warning(disable : 4996)
  #pragma warning(disable : 4996)
Line 7: Line 9:
  #define LOSS 125/128
  #define LOSS 125/128
  int main(){
  int main(){
  int repeat_num; //입력받을 개수
  int repeat_num;  
int i = 0;
  int j = 0;
  int j = 0;
  char data_case[9] = { 'B', 'K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y'}; //데이터 단위 배열
  char data_case[9] = { 'B', 'K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y'};
  char test_string[10]; //입력받는것
  char test_string[10];  
  char data_input;// 데이터 단위 저장
  char data_input;
    float temp = 1;
float temp = 1;
  float loss = 1;
  float loss = 1;
  scanf("%d", &repeat_num);
  scanf("%d", &repeat_num);
  for (int i = 1; i <= repeat_num; i++)
  for (i = 1; i <= repeat_num; i++)
  {
  {
  temp = 1;
  temp = 1;
  loss = 0;
  loss = 0;
  j = 0;
  j = 0;
  scanf("%s", test_string); // 입력 받음
  scanf("%s", test_string);  
   
   
  while (test_string[j++] != '[');
  while (test_string[j++] != '[');
  //찾음
 
  data_input = test_string[j];
  data_input = test_string[j];
  j = 0;
  j = 0;
Line 37: Line 40:
   
   
  }
  }
}



Latest revision as of 12:05, 22 September 2014

https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&category=595&page=show_problem&problem=4553 권준혁 소스코드

#pragma warning(disable : 4996)


#include<stdio.h>
#include<string.h>
#define LOSS 125/128
int main(){
	int repeat_num; 
	int i = 0;
	int j = 0;
	char data_case[9] = { 'B', 'K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y'};
	char test_string[10]; 
	char data_input;
	float temp = 1;
	float loss = 1;
	scanf("%d", &repeat_num);
	for (i = 1; i <= repeat_num; i++)
	{
		temp = 1;
		loss = 0;
		j = 0;
		scanf("%s", test_string); 

		while (test_string[j++] != '[');
		
		data_input = test_string[j];
		j = 0;
		while (data_case[j++] != data_input) {
			temp = temp * ((float)125/(float)128);
		}

		loss = 1 - temp;
		printf("Case #%d = %.2f\%\n", i,  100 * loss);
				

	}

}