// Sn=a+aa+aaa+aaaa+aaaaa 5 , a , :2+22+222+2222+22222
#include <stdio.h>
int main()
{
int a,n,sum;
int i,j;
sum = 0;
printf(" a ");
scanf("%d%d",&a,&n);
j = a;
for(i = 1;i <= n;i++)
{
sum = sum+a;
a = j + 10*a;
}
printf("Sn = %d",sum);
}
//2. , C , 。0
#include <stdio.h>
int main()
{
int c;
int count;
count =0;
while((c = getchar()) != EOF)
{
if(c == '{')
count++;
if(c == '}')
count--;
}
if( 0 == count)
printf(" ");
else
printf(" ");
return 0;
}
// , , ,
#include <stdio.h>
#include <stdlib.h>
int main()
{
int a,c;
int count;
a = 1;
count = 0;
while((c = getchar())!= EOF)
{
if(a == 1)
{
a = 0;
count++;
printf("%d",count);
}
putchar(c);
if(c == '
')
{
a = 1;
}
}
return 0;
}
// ,
#include <stdio.h>
void swap(int v[],int a,int b)
{
int temp;
temp = v[a];
v[a] = v[b];
v[b] = temp;
}
void qsort(int v[],int left,int right)
{
int i,last; //last
if(left >= right) // ,
return;
swap(v,left,(left+right)/2); // ,
last = left;
for(i = left +1;i <= right;i++) //v[left] ,
{
if(v[i] < v[left])
swap(v,++last,i); //++last swap()
}
swap(v,left,last); // last
qsort(v,left,last-1); //
qsort(v,last+1,right); //
}
int main()
{
int arry[10];
int i;
i = 0;
for(i = 0;i <sizeof(arry)/sizeof(arry[0]);i++)
{
scanf("%d",&arry[i]);
}
qsort(arry,0,sizeof(arry)/sizeof(arry[0])-1);
printf(" %d
",arry[0]);
printf(" %d",arry[9]);
return 0;
}
// 1.2.3.4 3
#include <stdio.h>
int main()
{
int hundreds,tens,ones;
hundreds = 0;
tens = 0;
ones = 0;
for(hundreds = 1;hundreds <= 4;hundreds ++)
{
for(tens = 1;tens <= 4;tens ++)
{
for(ones = 1;ones <= 4;ones ++)
{
if(ones != tens && tens != hundreds && hundreds != ones)
{
printf("%d%d%d
",hundreds,tens,ones);
}
}
}
}
return 0;
}