current position:Home>Zhejiang University pat class B 1048 test points 4 and 5 cannot pass, solution
Zhejiang University pat class B 1048 test points 4 and 5 cannot pass, solution
2022-02-04 16:50:20 【CSDN Q & A】
As shown in the figure , At present, the test output of the examples I use is correct , Solve what examples will make mistakes or how to modify them to pass the test points 4 and 5, thank you !
#include<stdio.h>char A[100],B[100];int max(int a,int b){ if (a>=b) return a; else return b;}void zero_padding(int len_a,int len_b)// The rule entered is len_a>len_b{ int num_0,i; if (len_a>len_b)// Yes B Zero compensation { num_0 = len_a-len_b; for (i=len_b-1;i>=0;i--) B[i+num_0] = B[i]; for (i=0;i<num_0;i++) B[i] = '0'; } else // Yes a Zero compensation { num_0 = len_b-len_a; for (i=len_a-1;i>=0;i--) A[i+num_0] = A[i]; for (i=0;i<num_0;i++) A[i] = '0'; }}int main(){ int i,len,temp; char a; int lenA = 0; int lenB = 0; for (i=0;i<100;i++) { scanf("%c",&a); if (a==' ') break; A[i] = a; lenA++; } for (i=0;i<100;i++) { scanf("%c",&a); if (a=='\n') break; B[i] = a; lenB++; } if (lenA!=lenB)// The length is not the same , High zero filling operation zero_padding(lenA,lenB); len = max(lenA,lenB); int odd_even;// If it is equal to 1, It is odd. ;0 Even digit if (len%2==0)// Judge who comes first odd_even = 0; else odd_even = 1; for (i=0;i<len;i++) { if (odd_even==1)// Odd number { temp = (B[i]+A[i]-48*2)%13; switch (temp){ case 10: temp = 'J'-48;break; case 11: temp = 'Q'-48;break; case 12: temp = 'K'-48;break; default: break;//J representative 10、Q representative 11、K representative 12 } printf("%c",(temp+48)); odd_even = 0; } else { temp = B[i]-A[i]; if (temp<0) temp += 10; printf("%d",temp); odd_even = 1; } } return 0;}
copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.
https://en.cdmana.com/2022/02/202202041650183186.html
The sidebar is recommended
- What are the advantages of real-time data processing based on maxcompute?
- Android source code analysis Series 1 - activity startup and interface loading, HTML5 mobile terminal development interview
- What are the similarities and differences between worker and excutor?
- Android source code analysis: implementation principle of lrucache caching mechanism, self-evaluation of Android development resume
- MySQL field name batch case conversion, Java work in 2021 may be more difficult to find
- DTS self built MySQL synchronizes to RDS. What SQL operations does MySQL support synchronization?
- MySQL Optimization: Performance Analysis of like and = in where, Java Architect growth express updated to
- What is ECS (Elastic Compute service)?
- What are the differences among the three Android annotation frameworks dagger, hilt and Koin?, Retrofit benefits
- What is the difference between MySQL hash index and B + tree?
guess what you like
-
Why ECS?
-
What are the permission requirements for DTS self built Mysql to synchronize to RDS MySQL database account?
-
What is the difference between MySQL inner connection, left connection and right connection?
-
What are the two shared variables provided by spark?
-
What does optimizing shard number mean?
-
What are the four components of Hadoop?
-
DTS self built MySQL is synchronized to RDS MySQL database. What is the method of account creation and authorization?
-
What are the main functional components of ECS?
-
What are the common billing methods for ECS?
-
What is the relationship between serverless and logging?
Random recommended
- How many layers does the MySQL logical architecture diagram have?
- What is the function of shard number?
- Why do we need MapReduce?
- What are the three paradigms of database?
- What are the common developer tools for calling ECS APIs?
- Configuration and description of source database information synchronized from DTS self built Mysql to RDS MySQL?
- What are the trends and challenges of serverless?
- What are the MySQL permission tables?
- What is the process of installing httpd service and PHP in ganglia?
- What is the role of Alibaba cloud toolkit?
- What is the log centralization of serverless applications?
- Configuration and description of target database information synchronized from DTS self built Mysql to RDS MySQL?
- HTML common tag examples
- Laravel statement reports an error. How to solve it?
- Please answer the questions about # C #!
- Use pagination JS paging plug-in paging, get the number of pages, but click the next page without refreshing the data
- C + + keyboard input, sorting, list output
- Technologies needed for wechat applet development
- The expression has been given to find the image?
- OSPF address configuration of switch
- Let's see how to correct this mistake. I didn't find it myself.
- PCIe TX / RX pin constraint problem
- HDU1096 presentation wrong
- Does anyone understand why the first process will operate through P and the second process will block at p?
- Data structure PTA questions do not know how to change
- On the grid position and width of Tkinter
- Use of react material UI 5.0 components
- Android modifies the interface displayed on the white screen through the theme of activity
- When configuring Powermode in vscode, expected comma is displayed
- Stc89c52rc controls the stepping motor, and the program card is in the first line of main,
- What's the difference between the same sentence?
- Expression 1 + 4 / 5 + 15 & lt; The value of 7 + 4% 5 + (8,10) is
- After the spring boot project is jar packaged and deployed to alicloud server, init datasource error is displayed. But local operation is good.
- The automated test tool RF cannot modify the font size
- The problem that DSS + FTP cannot be played online
- How to automatically execute pycharm file after clicking it
- How to solve the problem that the raspberry pie prompt cannot locate the software package when installing ngnix?
- How should I make up this problem? Please ask me
- Beg, an exercise problem, can't figure out a way of thinking
- How to judge whether the folding screen is unfolded when there is a problem of folding screen adaptation at the mobile terminal?