• 颜色反转


    题目链接: http://exercise.acmcoder.com/online/online_judge_ques?ques_id=3340&konwledgeId=40

    解题思路: 直接模拟。

     1 #include <bits/stdc++.h>
     2 using namespace std;
     3 
     4 int getOrder(char ch)
     5 {
     6     if (isdigit(ch)) return ch-'0';
     7     return ch-'A'+10;
     8 }
     9 
    10 char getChar(int x)
    11 {
    12     if (x<10) return '0' + x;
    13     return 'A' + x - 10;
    14 }
    15 
    16 int char2int(char *s)
    17 {
    18     return getOrder(s[0])*16 + getOrder(s[1]);
    19 }
    20 
    21 void int2char(int x, char *s)
    22 {
    23     int i = x / 16;
    24     int j = x % 16;
    25     s[0] = getChar(i);
    26     s[1] = getChar(j);
    27 }
    28 
    29 int main()
    30 {
    31     char s[10];
    32     while (scanf("%s", s) != -1)
    33     {
    34         int x = char2int(s+1);
    35         int2char(255-x,s+1);
    36         x=char2int(s+3);
    37         int2char(255-x,s+3);
    38         x=char2int(s+5);
    39         int2char(255-x,s+5);
    40         printf("%s
    ",s);
    41     }
    42     return 0;
    43 }
  • 相关阅读:
    块级元素和内联元素
    cookie和session 区别
    hihernate一对多关联映射
    --查询50到80行数据
    单表查询
    表空间 用户
    进程遍历模块遍历
    字符转换函数
    控件综合2
    清理文件2
  • 原文地址:https://www.cnblogs.com/djingjing/p/8992996.html
Copyright © 2020-2023  润新知