提交记录 #516
提交时间:2025-01-03 18:38:20
语言:c
状态:Unaccepted
编译情况:编译成功
code.c: In function ‘change’:
code.c:11:17: warning: array subscript has type ‘char’ [-Wchar-subscripts]
11 | erjinzhi[k]=a%2;
| ^
code.c: In function ‘chongpai’:
code.c:29:18: warning: array subscript has type ‘char’ [-Wchar-subscripts]
29 | bianmashu[n]+=erjinzhi[k]*pow(2,5-w);
| ^
code.c:29:31: warning: array subscript has type ‘char’ [-Wchar-subscripts]
29 | bianmashu[n]+=erjinzhi[k]*pow(2,5-w);
| ^
code.c: In function ‘main’:
code.c:50:5: warning: implicit declaration of function ‘gets’; did you mean ‘fgets’? [-Wimplicit-function-declaration]
50 | gets(yuan);
| ^~~~
| fgets
/usr/bin/ld: /tmp/ccbCU3lK.o: in function `main':
code.c:(.text.startup+0x12): warning: the `gets' function is dangerous and should not be used.
固定测试点#1:
固定测试点#2:
固定测试点#3:
额外测试点#1:
H17【选做•同学出题】动手实现Base64算法
#include<stdio.h>
#include<string.h>
#include<math.h>
char yuan[10000],p=0,k=0,n=0,result[10000];
char dic[65]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
int erjinzhi[100000]={0},bianmashu[100000]={0},yu=0;
void change(int a){
k=p+7;
while (k>=p){
erjinzhi[k]=a%2;
a/=2;
k--;
}
// int i;//check
// for (i=p;i<p+8;i++) printf("erjinzhi=%d\n",erjinzhi[i]);//check
// printf("\n");//check
p+=8;
}
void chongpai(int g){
while (g%3!=0){
p+=8;
g++;
yu++;
}
k=0;
int w=0;
while (k<=p){
bianmashu[n]+=erjinzhi[k]*pow(2,5-w);
k++;
w++;
if (w==6){
w=0;
// printf("bianmashu=%d\n",bianmashu[n]);//check
n++;
}
}
}
void bianma(){
int i;
for (i=0;i<n;i++){
result[i]=dic[bianmashu[i]];
}
for (i=n-yu;i<n;i++){
if (result[i]=='A') result[i]='=';
}
printf("%s\n",result);
}
int main(){
gets(yuan);
int i,g=strlen(yuan);
for (i=0;i<strlen(yuan);i++){
change((int)yuan[i]);
}
chongpai(g);
bianma();
return 0;
}