11148.c
unknown
c_cpp
2 years ago
1.4 kB
8
Indexable
// 11148
#include <stdio.h>
#include<stdbool.h>
#include<math.h>
#include<stdlib.h>
#include<ctype.h>
#include<string.h>
#include<limits.h>
#define SIZE 30
char Find_Missing(int N, char input[SIZE]) {
char output = '0';
// to lower
for(int i=0; i<N; i++){ input[i] = tolower( input[i] ); }
for(int i=N; i<SIZE; i++){ input[i] = '\0'; }
// printf("input = %s\n", input);
// sort
for(int i=0; i<N; i++){
for(int j=0; j<N-i-1; j++){
// printf("j = %d\n", j);
if(input[j+1] == '\0'){ continue; }
if(input[j] > input[j+1]){
char temp = input[j];
input[j] = input[j+1];
input[j+1] = temp;
}
}
// printf("input = ");
// for(int k=0; k<N; k++){ printf("%c ", input[k]); }
// printf("\n");
}
// printf("strlen = %ld, N = %d\n", strlen(input), N);
// printf("input = %s\n", input);
if(N==1){ return '0'; }
// scanning
char c = input[0];
while(c != input[N-1]){
int flag = 0;
for(int i=0; i<N; i++){
if(input[i] == c){ flag=1; }
}
if( flag == 0 ){
output = c;
// printf("missing %c\n", c);
// printf("output = %c\n", output);
}
c++;
}
return output;
}
/*
int main() {
int N = 0;
char input[SIZE], output;
while(scanf("%c", &input[N]) != EOF){
N++;
}
output = Find_Missing(N, input);
printf("%c\n", output);
return 0;
}
*/Editor is loading...
Leave a Comment