main()
{ char *p,s[6];int n;
p=s;
gets(p);
n=0;
while(*(p)!='\0')
{n=n*8+*p-'0';
p++;}
printf("%d",n);
}
main()
{
long sum=4,s=4;
int j;
for(j=2;j<=8;j++)/*j is place of number*/
{ printf("\n%ld",sum);
if(j<=2)
s*=7;
else
s*=8;
sum+=s;}
printf("\nsum=%ld",sum);
}
#include "stdio.h"
#include "math.h"
main()
{ int a,b,c,d;
scanf("%d",&a);
for(b=3;b<=a/2;b+=2)
{ for(c=2;c<=sqrt(b);c++)
if(b%c==0) break;
if(c>sqrt(b))
d=a-b;
else
break;
for(c=2;c<=sqrt(d);c++)
if(d%c==0) break;
if(c>sqrt(d))
printf("%d=%d+%d\n",a,b,d);
}
}
main()
{ long int m9=9,sum=9;
int zi,n1=1,c9=1;
scanf("%d",&zi);
while(n1!=0)
{ if(!(zi/sum)) /*若整数a除以非零整数b,商为整数,且余数为零, 我们就说a能被b整除(或说b能整除a),记作b|a。注意b为0则不叫整除。*/
n1=0;
else
{m9=m9*10;
sum=sum+m9;
c9++;
}
}
printf("%ld,can be divided by %d \"9\"",sum,c9);
}
main()
{int a,i,aa[4],t;
scanf("%d",&a);
aa[0]=a%10;
aa[1]=a%100/10;
aa[2]=a%1000/100;
aa[3]=a/1000;
for(i=0;i<=3;i++)
{aa[i]+=5;
aa[i]%=10;
}
for(i=0;i<=3/2;i++)
{t=aa[i];
aa[i]=aa[3-i];
aa[3-i]=t;
}
for(i=3;i>=0;i--)
printf("%d",aa[i]);
}
猴子把多的一个扔入海中,拿走了一份。第二只猴子把剩下的桃子又平均分成五份,又多了
一个,它同样把多的一个扔入海中,拿走了一份,第三、第四、第五只猴子都是这样做的,
问海滩上原来最少有多少个桃子?
1.程序分析:
2.程序源代码:
main()
{
int i,m,j,k,count;
for(i=4;i<10000;i+=4)
{
count=0;
m=i;
for(k=0;k<5;k++)
{
j=i/4*5+1;
i=j;
if(j%4==0)
count++;
else
break;
}
i=m;
if(count==4)
{
printf("%d\n",count);
break;
}
}
}
1. 程序分析:
2.程序源代码:
#define nmax 50
main()
{
int i,k,m,n,num[nmax],*p;
printf("please input the total of numbers:");
scanf("%d",&n);
p=num;
for(i=0;i
int fac (int n)
{
if(n==1)
return 1;
return n*fac(n-1);
}
public static string RemoveExtraCharAndWithoutSort(string str)
{
if (string.IsNullOrEmpty(str))
{
return null;
}
int[] tempArr = new int[256];
string newStr = string.Empty;
for (int i = 0; i < str.Length; i++)
{
if (tempArr[str[i]] == 0)
{
tempArr[str[i]] = 1;
newStr += str[i];
}
}
return newStr;
}
element *CLinkList::FindMToLastElement(int m)
{
element *previous, *current;
previous = current = head;
// 访问前m-1个节点
for(int i = 0; i < m-1; ++i)
{
current = current->next;
if(current == NULL)
{
printf("number overstep\n");
return NULL;
}
}
//previous指针和current指针一起向尾移动
while(current->next != NULL)
{
previous = previous->next;
current = current->next;
}
//返回previous指针
return previous;
}