PAT甲级题库题解1001

news/2024/7/24 2:30:43 标签: c语言

准备三月份的PAT记录每天的题解
PAT甲级1001

#include<bits/stdc++.h>
using namespace std;

int main(void)
{
    freopen("pat0314/in.txt","r",stdin);
    int a,b;
    cin>>a>>b;
    int c = a + b;
    if(c < 0)
    {
        printf("-");
        c = -c;
                if(c < 1000)
        {
            printf("%d",c);
        }
        else if(c >= 1000 && c < 1000000)
        {
            int temp = c /1000;
            printf("%d,",temp);
            printf("%03d",c % 1000);
        }
        else 
        {
            int temp = c / 1000000;
            printf("%d,",temp);
            int temp1 = c % 1000000 / 1000;
            printf("%03d,",temp1);
            int temp2 = c % 1000;
            printf("%03d",temp2);
        }
    }
    else 
    {
        if(c < 1000)
        {
            printf("%d",c);
        }
        else if(c >= 1000 && c < 1000000)
        {
            int temp = c /1000;
            printf("%d,",temp);
            printf("%03d",c % 1000);
        }
        else 
        {
            int temp = c / 1000000;
            printf("%d,",temp);
            int temp1 = c % 1000000 / 1000;
            printf("%03d,",temp1);
            int temp2 = c % 1000;
            printf("%03d",temp2);
        }
    }
    return 0;
}

http://www.niftyadmin.cn/n/1036642.html

相关文章

spring注解方式运行报错 java: 错误: 无效的源发行版:17

1 Project SDK 和 Project language level 要版本一直 2 Modules 查看版本 看JDK版本是否正确 3 Settings里面查看 java Compiler 里面的jdk版本是否一致 如果上述都没有问题 那么恭喜你 遇到了最麻烦的一种 spring与JDK 版本不匹配 以下是版本对照表 大家可以参考去重新…

PATA 题解 1002

PATA 1002题解 水题 没什么思路 #include<bits/stdc.h> using namespace std;const int MAXN 1010; double res[MAXN]; int main(void) { // freopen("pat0314/in.txt","r",stdin);int a,b;cin>>a;int maxExponent -1;for(int i 0;i<…

Uncaught (in promise) DOMException: Failed to execute ‘replaceState‘ on ‘History‘: A history state o

这是一个访问路径的错误 简单说 就是你访问的路径不符合 HTTP规范 好好检查一下 一般就是 多了斜杠 或者少了斜杠 多了某个符号 少了某个符号 好好检查一下就能解决的问题

PAT甲级题解1003

PAT甲级题库题解1003 For each test case, print in one line two numbers: the number of different shortest paths between c1 and c2​​ , and the maximum amount of rescue teams you can possibly gather. All the numbers in a line must be separated by exactly one…

PAT甲级题解1004

注意的是m代表的是the number of non-leaf nodes 要看清楚题意&#xff0c;一开始把n - m认为是输入的行数了… 利用vector特性 题意大致是寻找每层叶结点的个数&#xff0c;DFS遍历这棵树&#xff0c;遍历时统计即可。 #include<bits/stdc.h> using namespace std;cons…

uniapp uni-icons 组件为例 带着大家使用并熟悉一次文档

首先 要在应用市场中导入 这是个前提 https://ext.dcloud.net.cn/plugin?id28 uni的组件都可以直接进入官网 https://uniapp.dcloud.net.cn/ 然后点击右上角的搜索 直接在输入框中 搜索 uni-icons 下面内容就都出来了 先看下面的 API 看看每个字段都是干什么的 这里 我们…

PAT甲级题解1005

一道水题 注意为0的时候特判输出即可 #include<bits/stdc.h> using namespace std; const string a[] {"zero","one","two","three","four","five","six","seven","eight"…

PAT甲级题解 1006

一道sort水题 #include<bits/stdc.h> using namespace std; const int MAXN 1100; struct node {string name;int hh;int mm;int ss;int beginTime;int endTime;}person[MAXN]; bool beginCmp(node a,node b) {return a.beginTime < b.beginTime; } bool endCmp(nod…