HelloWorld编译器
来源:互联网 发布:vm14无法识别mac os x 编辑:程序博客网 时间:2024/06/11 15:58
题目描述 Description
请编程判断一个负责打印HelloWord的程序是否能正确运行。
编译错误输出CE
答案错误输出WA
答案正确输出AC
输入描述 Input Description
一个C语言编写的HelloWord程序,输出HelloWord字符串,后跟一个换行符\n。
输出描述 Output Description
判断该程序的对错,输出CE或WA或AC
样例输入 Sample Input
#include "stdio.h" int main(){ printf("HelloWorld\n"); return 0; }
样例输出 Sample Output
AC
数据范围及提示 Data Size & Hint
数据中只包含样例输入中包含的关键字(除了HelloWorld),并且按照样例中的顺序给出。另外还可能包含<stdio.h>。
只需要判断每一句话是否对应合法即可。
#include <iostream>#include <cstdio>#include <string.h>using namespace std;int main(){char map[]="#include\"stdio.h\"intmain(){printf(\"HelloWorld\\n\");return0;}";char str[1000]={0};char s;int i=0,j=0,x=0,y=0,x1=0,y1=0;while(scanf("%c",&s)!=EOF){if(str[i-1]!='\\'&&s=='\n')continue;if(s!=' ')str[i++]=s;}int t=0; for(i=0;str[i];i++){if(str[i]=='H')x=i;if(str[i]=='n'&&str[j-1]=='\\')y=i;if(map[j]=='H') x1=j;if(map[j]=='n'&&map[j-1]=='\\')y1=j;if(str[i]!=map[j++])t=1;}for(j=x;j<=y;j++){if(str[j]!=map[x1++])break;}if(j<=y){printf("WA\n");return 0;}if(t==0){printf("AC\n");return 0;}printf("CE\n");}
0 0
- HelloWorld编译器
- objective-c HelloWorld实践 (gcc编译器)
- ubuntu10.10下测试gcc,gfortran编译器的helloworld工程
- C#命令行编译器csc.exe编译HelloWorld程序
- Linux中GCC编译器运行第一个程序“Helloworld!”
- helloworld
- HelloWorld
- helloworld
- helloworld
- HelloWorld
- HelloWorld
- HelloWorld
- HelloWorld
- HelloWorld
- HelloWorld
- helloWorld!
- helloworld!
- HelloWorld
- 设计模式
- DB2错误信息【按照sqlcode排序】
- length方法和subString方法
- Idea Maven项目搭建spring 框架
- java基础1:Java简介
- HelloWorld编译器
- 搭建wamp环境,数据库基础知识
- 网易笔试—动态规划
- java基础2:Java语法定义规范
- 练习题:选择器和选择好友
- mongoc_collection_update
- ajax基础 和 Jquery的ajax
- 分割字符串
- sql 存储过程里的if else while