2025年济南大学计算机考研复试机试真题
2025年济南大学计算机考研复试上机真题
历年济南大学计算机考研复试上机真题
历年济南大学计算机考研复试机试真题
更多学校题目开源地址:https://gitcode.com/verticallimit1/noobdream
N 诺 DreamJudge 题库:输入 “学校名称” 即可筛选该校历年机试真题,题目均在考纲范围内,按难度自动排序。还可搭配《计算机考研机试攻略》刷题,书中题目可通过题号直接在题库中查找。
判断回文数
题目描述
Time Limit: 1000 ms
Memory Limit: 256 mb
第一题判断一个整数是否为回文数。
例如123321是回文数,123123不是回文数。
输入输出格式
输入描述:
多组测试数据输入。 输入一个整数,不超过10^9。
输出描述:
对于每一行输入,如果这个数是回文数则输出Yes,如果不是则输出No。
输入输出样例
输入样例#:
11 991
输出样例#:
Yes No
代码一
- #include <stdio.h>
- #include <string.h>
- char *reverse(char *s)
- {
- for(int i=0,j=strlen(s)-1;i<j;i++,j--)
- {
- if(s[i]!=s[j])
- return "No\n";
- }
- return"Yes\n";
- }
- int main()
- {
- char s1[9999];
- while(scanf(" %s",s1)!=EOF)
- {
- printf("%s",reverse(s1));
- memset(s1,'\0',sizeof(s1));
- }
- }
代码二
- #include<iostream>
- #include<string>
- #include<set>
- #include<cmath>
- #include<algorithm>
- #include<map>
- #include<vector>
- using namespace std;
- string s;
- int main(){
- while(cin>>s){
- bool flag=true;
- for(int i=0,j=s.size()-1;i<j;)
- {
- if(s[i]!=s[j])
- {
- flag=false;
- cout<<"No"<<endl;
- break;
- }
- i++;
- j--;
- flag=true;
- }
- if(flag==true)cout<<"Yes"<<endl;
- }
- return 0;
- }
代码三
- #include<bits/stdc++.h>
- using namespace std;
- #define int long long
- #define endl '\n'
- #define INF 0x3f3f3f3f
- signed main() {
- ios::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);
- string s;
- while(cin>>s){
- string s1;
- s1=s;
- reverse(s.begin(),s.end());
- if(s1==s) cout<<"Yes"<<endl;
- else cout<<"No"<<endl;
- }
- return 0;
- }