UVA Solution 414 - Machined Surfaces in C++11 | Volume 4
UVA Online Judge Solution 414 - Machined Surfaces| Volume 4
UVA Problem Link - https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=6&page=show_problem&problem=355
Problem Name: 414 - Machined Surfaces
Problem Number : UVA - 414 - Machined Surfaces
Online Judge : UVA Online Judge Solution
Volume: 4
Solution Language : C++11
UVA Solution 414 - Machined Surfaces Code in in C++11 :
#include <stdio.h> #include <string.h> int main() { int n; while(scanf("%d", &n) == 1 && n) { char s[50]; getchar(); int i, j, shift = 0xfffff; int a[50], left, right; for(i = 0; i < n; i++) { gets(s); j = 0; while(s[j] != '\0' && s[j] == 'X') j++; left = j; while(s[j] != '\0' && s[j] != 'X') j++; right = j; a[i] = right - left; if(a[i] < shift) shift = a[i]; } int sum = 0; for(i = 0; i < n; i++) sum += a[i]-shift; printf("%d\n", sum); } return 0; }
No comments:
Post a Comment