|
发表于 2014-5-27 01:33:42
|
显示全部楼层
下面是好友 后来 的程序,实现了寻找:
- #include "stdafx.h"
- #include <stdlib.h>
- #include <string.h>
- #include <math.h>
- int main(int argc, char* argv[])
- {
- void deletebit(char array[],int i);
- int n;
- printf("please input the value of n:");
- scanf("%d",&n);
- for(int a = 10; a < n ;a++)
- {
- int b = a;
- char array[100];
- itoa(a,array,10);
- char arraycopy[100];
- strcpy(arraycopy,array);
- int LEN = strlen(array);
- for(int i = 0; i < LEN; i++)
- {
- deletebit(array,i);
- int b = atoi(array);
- if(a + b == n)
- {
- printf("%d + %d = %d\t",a,b,n);
- break;
- }
- else
- strcpy(array,arraycopy);
- }
- a = b;
- }
- system("pause");
- return 0;
- }
- void deletebit(char array[],int i)
- {
- for(; i < strlen(array); i++)
- {
- array[i] = array[i+1];
- }
- }
复制代码 |
|