当前位置:编程学习 > C/C++ >>

九度OJ 题目1127:简单密码

********************************  
 *    日期:2013-2-6 
 *    作者:SJF0115  
 *    题号: 九度OJ 题目1127:简单密码 
 *    来源:http://ac.jobdu.com/problem.php?pid=1127 
 *    结果:AC  
 *    来源:2008年北京大学图形实验室计算机研究生机试真题 
 *    总结: 
**********************************/   
#include<stdio.h>   
#include<stdlib.h>   
#include<string.h>   
char password[26] = {'V','W','X','Y','Z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U'};  
int main()  
{  
    int n,i;  
    char start[11],end[4],text[201];  
    //freopen("C:\\Users\\SJF\\Desktop\\acm.txt","r",stdin);    
    while(gets(start) && strcmp(start,"ENDOFINPUT") != 0)  
    {  
        gets(text);  
        for(i = 0;i < strlen(text);i++){  
            if(text[i] >= 'A' && text[i] <= 'Z'){  
                text[i] = password[text[i] - 'A'];  
            }  
        }  
        gets(end);  
        for(i = 0;i < strlen(text);i++){  
            printf("%c",text[i]);  
        }  
        printf("\n");  
    }  
    return 0;  
}  
 
/********************************* 
 *    日期:2013-2-6
 *    作者:SJF0115 
 *    题号: 九度OJ 题目1127:简单密码
 *    来源:http://ac.jobdu.com/problem.php?pid=1127
 *    结果:AC 
 *    来源:2008年北京大学图形实验室计算机研究生机试真题
 *    总结:
**********************************/ 
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
char password[26] = {'V','W','X','Y','Z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U'};
int main()
{
    int n,i;
char start[11],end[4],text[201];
//freopen("C:\\Users\\SJF\\Desktop\\acm.txt","r",stdin); 
    while(gets(start) && strcmp(start,"ENDOFINPUT") != 0)
    {
gets(text);
for(i = 0;i < strlen(text);i++){
if(text[i] >= 'A' && text[i] <= 'Z'){
text[i] = password[text[i] - 'A'];
}
}
gets(end);
for(i = 0;i < strlen(text);i++){
printf("%c",text[i]);
}
printf("\n");
    }
    return 0;
}
 
 
补充:软件开发 , C++ ,
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,