首页 > 试题广场 >

奇偶校验

[编程题]奇偶校验
  • 热度指数:10117 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 64M,其他语言128M
  • 算法知识视频讲解
输入一个字符串,然后对每个字符进行奇校验,最后输出校验后的二进制数(如'3’,输出:10110011)。

输入描述:
输入包括一个字符串,字符串长度不超过100。


输出描述:
可能有多组测试数据,对于每组数据,
对于字符串中的每一个字符,输出按题目进行奇偶校验后的数,每个字符校验的结果占一行。
示例1

输入

3
3a

输出

10110011
10110011
01100001
头像 木何
发表于 2023-02-25 20:15:40
#include <bitset> #include <iostream> using namespace std; int main() { char s; while (cin >> s) { bitset<8> 展开全文
头像 pinkbin
发表于 2023-02-20 00:28:30
#include <bitset> #include <iostream> using namespace std; int main() { string s; while (cin >> s) { // 注意 while 处理多个 case 展开全文
头像 在考古的小鱼干很有气魄
发表于 2023-03-06 11:46:45
#include <bits/stdc++.h> #define MAX 10 using namespace std; int res[MAX]; int d2b(int n) { int i = 0; memset(res, 0, sizeof(res)); 展开全文
头像 mean._
发表于 2023-03-02 11:22:47
#include <stdio.h> #include <string.h> void check(int a) { //printf("%d\n",a); int b[8]; memset(b, 0, sizeof(b)); int num= 展开全文
头像 牛客218094273号
发表于 2024-03-17 10:48:10
#include<iostream> #include<string> using namespace std; //十进制转换成二进制 int zhuanhuan(int n){ int sum=0,p=1; while(n>0){ int t=n%2; 展开全文
头像 宁静的冬日
发表于 2022-03-07 20:30:40
#include<iostream> using namespace std; #include<string> #include<algorithm> //转成二进制 string trans(int n) { if (n == 0)return "0"; 展开全文
头像 小徐小徐啊啊
发表于 2024-03-15 16:07:48
#include <stdio.h> #include<string.h> int main() { char a[100]; int c[8]={1,2,4,8,16,32,64,128}; while(scanf("%s",a)!=EOF) { 展开全文
头像 爱交友的马后炮炮手在创作
发表于 2024-03-02 16:01:20
#include <stdio.h> #include <string.h> void check(char c){ int a[8]={0}; int b=c; memset(a,0,sizeof(a));//此函数在string.h内部 i 展开全文
头像 小花Student
发表于 2024-02-18 20:39:30
#include<iostream> //实现字符的奇校验 void addParity(char c) { int count = 0; for(int i = 0;i < 8;i++) { if((c >> i) & 展开全文
头像 持螯把酒
发表于 2023-02-20 23:24:07
#include <iostream> #include <stdio.h> #include <stdlib.h> #include <bitset> using namespace std; int main() { char x; 展开全文