n1[i+1] = 0; char c = str[i]; sscanf(&str[i], "%1d", &n1[j]); // 将字符串中的一个字符转换为整数 //printf("i=%d j=%d v=%c\n",i,j,str[i]); if (c >= '0' && c <= '9'){j=j-1;} } // printf("n1="); // for (i=0;i<21;i++){ // printf("%d"...
c语言编程练习题:7-49 Have Fun with Numbers #include<stdio.h>#include<stdlib.h>#include<string.h>intis_same_digits(int*arr1,int*arr2){intarr_d_1[10]={0};intarr_d_2[10]={0};intd1=0,d2=0;inti;intv1,v2;for(i=0;i<21;i++){v1=arr1[i];v2=arr2[i];if(v1!=0){d1...
原题链接:数据结构-起步能力自测题 自测-4 Have Fun with Numbers 老规矩,大整数用字符数组,然后找找规律来做。 #include<stdio.h>#include<string.h>intmain(){charch,a[21];inti=0,j,n,b[10]={0};intx,r=0,flag=0,flag2=0;scanf("%s",a);n=strlen(a);charc[n+1];j=n;c[j]='\0'...
PTA刷题笔记(C语言) | 7-49 Have Fun with Numbers (20分),开始刷题,感觉代码量和基础太渣了,导致数据结...
Have fun with numbers #include<stdio.h>#include<stdbool.h>#include<stdlib.h>#include<string.h>intmain(intargc,charconst*argv[]){charstart[21];charend[21];intflag1=1; gets(start);intt,i,j,s; t=strlen(start);intm=0;if((start[0]-'0')*2>=10){...
// 1023. Have Fun with Numbers.cpp: 主项目文件。 #include "stdafx.h" #include <cstdio> #include <cstring> int hash[10]; void doubleOperate(char *str,char *pStr){ } int main() { memset(hash,0,sizeof(hash)); char str[23],pStr[23]; ...
1023 Have Fun with Numbers (附详细注释,逻辑分析),写在前面正确立即题目permutation:排列(方式);组合(方式)通用方法循环遍历计
PAT_甲级_1023 Have Fun with Numbers 题目大意: 给出一个长度不超过20的整数,问这个整数乘以2以后的数位是否为原数数位的一个排列 算法思路: 由于长度有可能达到20位,超过了long long的存储范围,所以这里采用string存储输入的整数。该题只需要解决两个问题,第一个就是如何判断2个整数的互为排列,第二个就是...
which happens to be another 9-digit number consisting exactly the numbers from 1 to 9, only in a different permutation. Check to see the result if we double it again! Now you are suppose to check if there are more numbers with this property. ...
#include<iostream>#include<cstdio>#include<string>#include<string.h>#include<algorithm>usingnamespacestd;intmain(){#if ONLINE_JUDGE#elsefreopen("input.txt","r",stdin);#endifcharinput[21];scanf("%s",input);strings=input;intnum[10]={0};// 0->9boolisFun=true;for(inti=0;i<s.size()...