#30503: #1,4,8測試過不了 程式85%


tinakga920029@gmail.com (云婷)

學校 : 金門縣金城國中
編號 : 190665
來源 : [218.173.75.121]
最後登入時間 :
2022-06-03 12:21:10
a054. 電話客服中心 -- 板橋高中教學題 | From: [218.173.109.231] | 發表日期 : 2022-05-26 00:16

#include<stdio.h>
#include<string.h>
void cal(int,int);
int main(){
int input;
scanf("%d",&input);
cal(input/10,input%10);//使用自定義函數
}
void cal(int a,int b){
int temp=0,i;
char alphabet[27]={"ABCDEFGHIJKLMNOPQRSTUVWXYZ"};//利用兩個陣列建立表格,相呼應位置
int num[26]={10,11,12,13,14,15,16,17,34,18,19,20,21,22,35,23,24,25,26,27,28,29,32,30,31,33};
for(i=1;i<=8;i++){
temp+=(a%10)*i;
a=a/10;
}
 
 
for(i=0;i<=26;i++){
int check;//使用到區域變數和全域變數的概念temp每次回圈結束後仍不歸零,而check歸零
check=0;
check=((num[i]%10)*9+(num[i]/10)*1)+temp;
if(((check%10)!=0)&&((10-(check%10))==b)){
printf("%c",alphabet[i]);
}
else if(((temp%10)==0)&&(((10-(temp%10))%10)==b)){
printf("%c",alphabet[i]);
}
}
printf("\n");

}
 
#30513: Re: #1,4,8測試過不了 程式85%


cges30901 (cges30901)

學校 : 不指定學校
編號 : 30877
來源 : [101.136.203.77]
最後登入時間 :
2024-04-07 15:34:14
a054. 電話客服中心 -- 板橋高中教學題 | From: [59.115.10.38] | 發表日期 : 2022-05-26 22:05

1.
for(i=0;i<=26;i++){
2.
else if(((temp%10)==0)&&(((10-(temp%10))%10)==b)){
 
  1. 最大只有到25,這裡會超出陣列範圍
  2. temp改成check
 
ZeroJudge Forum