九度OJ 题目1197:奇偶校验

来源:互联网 发布:p2p网贷软件系统 编辑:程序博客网 时间:2024/06/18 13:53

原题链接http://ac.jobdu.com/problem.php?pid=1197
在自己电脑上跑应该是没有问题的
run
结果提交之后Compile Error,说是undefined reference to 'itoa' ,百度之后才知道这个itoa并不是C标准库函数。

/************************************************* * @Date    : 2017-09-16 20:54:31* @Author  : Lewis Tian (chasetichlewis@gmail.com)* @GitHub    : https://github.com/LewisTian* Copyright (c) 2017 Tich. All rights reserved.**************************************************/#include <stdio.h>#include <stdlib.h>#include <string.h>int main(int argc, char const *argv[]){    int n, i, count;    unsigned char str[101], c;    char out[10];    while(scanf("%s", str) != EOF) {        for (i = 0; i < strlen(str) ; ++i) {            count = 0;            c = str[i];            while(c) {                if (c>>1<<1 != c) {                    count++;                }                c = c>>1;            }            if (count % 2 == 0) {                c = str[i]|0x80;            } else {                c = str[i];            }            itoa(c, out, 2);            printf("%08s\n", out);        }    }    return 0;}
原创粉丝点击