View Code of Problem 3308

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#define inf 0x7fffffff

char alg[27]={"ABCDEFGHIJKLMNOPQRSTUVWXYZ"};
char alg1[27]={"VWXYZABCDEFGHIJKLMNOPQRSTU"};

int main() {
	char text[205];
	while(gets(text)&&strcmp(text,"ENDOFINPUT")!=0){
		gets(text);
		for(int i=0;i<strlen(text);i++){
			if(text[i]>='A'&&text[i]<='Z'){
				for(int j=0;j<27;j++){
					if(text[i]==alg[j]){
						text[i]=alg1[j];
						break;
					}
				}
			}
		}
		for(int i=0;i<strlen(text);i++){
			printf("%c",text[i]);
		}
		printf("\n");
		gets(text);
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 3308