标签:rds put printf ret ++ bsp ted get sum
1.
#include <stdio.h>
int main()
{
int a[10];
int i,j,k;
printf("input 10 numbers :\n");
for(i=0;i<10;i++)
scanf("%d",&a[i]);
printf("\n");
for(j=0;j<10;j++)
for(i=0;i<9-j;i++)
if(a[i]>a[i+1])
{k=a[i];a[i]=a[i+1];a[i+1]=k;}
printf("the sorted numbers :\n");
for(i=0;i<10;i++)
printf("%d\n",a[i]);
printf("\n");
return 0;
}
2.
#include <stdio.h>
int main()
{
int a[3][3];
int i,j,k=0;
printf("input numbers :\n");
for(i=0;i<3;i++)
for(j=0;j<3;j++)
scanf("%d",&a[i][j]);
for(i=0;i<3;i=i+2)
for(j=0;j<3;j=j+2)
k=k+a[i][j];
k=k+a[1][1];
printf("the sum :%d\n",k);
return 0;
}
3.
#include <stdio.h>
int main()
{
char s[81];
char c;
int i,n=0,w=0;
gets(s);
for(i=0;(c=s[i])!=‘\0‘;i++)
if(c==‘ ‘) w=0;
else if(w==0)
{w=1;
n++;
}
printf("The are %d words in this line.\n",n);
return 0;
}
4.
#include <stdio.h>
int main()
{
int i,j,a[100];
for(i=2;i<100;i++)
{
a[i]=i;
for(j=2;j<=i;j++)
{
if(j<i)
if(a[i]%j==0)
break;
if(a[i]-j==0)
printf("%d\n",a[i]);
}
}
return 0;
}
标签:rds put printf ret ++ bsp ted get sum
原文地址:https://www.cnblogs.com/P201821430029/p/10912104.html