#include <stdio.h>
int main(){
int age = 18;
float height = 1.85;
char unit = 'm';
printf("小明今年%d岁\n", age);
printf("小明身高%f%c\n", height, unit);
printf("%s","小明现在在慕课网上学习IT技术");
return 0;
}
int main(){
int age = 18;
float height = 1.85;
char unit = 'm';
printf("小明今年%d岁\n", age);
printf("小明身高%f%c\n", height, unit);
printf("%s","小明现在在慕课网上学习IT技术");
return 0;
}
2015-01-23
#include <stdio.h>
int main()
{
int sum = 0;
int i;
for(i=1; i<=10; i++)
{
printf("%d\n", i);
if(i>2)
goto LOOP;
}
LOOP:printf("结束for循环了....");
return 0;
}
这个也行啊
int main()
{
int sum = 0;
int i;
for(i=1; i<=10; i++)
{
printf("%d\n", i);
if(i>2)
goto LOOP;
}
LOOP:printf("结束for循环了....");
return 0;
}
这个也行啊
2015-01-22
#include <stdio.h>
int main()
{
int i, sum;
for(i=1, sum=0; i<=20; i++)
{
if(i%3!=0)
sum += i;
}
printf("sum=%d\n", sum);
return 0;
}
int main()
{
int i, sum;
for(i=1, sum=0; i<=20; i++)
{
if(i%3!=0)
sum += i;
}
printf("sum=%d\n", sum);
return 0;
}
2015-01-22
#include <stdio.h>
int main()
{
int m, n;
for(m=3; m<=50; m++)
{
for(n=2; n<m; n++)
{
if( m%n==0) break;
}
if(m == n)
printf("%d ", m);
}
return 0;
}
int main()
{
int m, n;
for(m=3; m<=50; m++)
{
for(n=2; n<m; n++)
{
if( m%n==0) break;
}
if(m == n)
printf("%d ", m);
}
return 0;
}
2015-01-22
#include <stdio.h>
int main()
{
double num1 = 2.5; //定义浮点型变量num1并赋值为2.5
int num=(int) num1;
printf("num的整数部分是%d\n", num);
return 0;
}
int main()
{
double num1 = 2.5; //定义浮点型变量num1并赋值为2.5
int num=(int) num1;
printf("num的整数部分是%d\n", num);
return 0;
}
2015-01-22
int main()
{
int arr1[] = {10,41,3,12,22};
int arr2[] = {1,2,3,4,5};
int i;
replaceMax(arr1,arr2[0]); //将数组arr1和数组arr2的第一个元素传入函数中
for(i=0;i<5;i++)
{
printf("%d ",arr1[i]);
}
return 0;
}
{
int arr1[] = {10,41,3,12,22};
int arr2[] = {1,2,3,4,5};
int i;
replaceMax(arr1,arr2[0]); //将数组arr1和数组arr2的第一个元素传入函数中
for(i=0;i<5;i++)
{
printf("%d ",arr1[i]);
}
return 0;
}
2015-01-22
#include <stdio.h>
int main() {
int num, sd, td, hd;
for( num =100;num <1000;num++)
{
hd = num/100;
sd = num/10%10;
td = num%10;
if(num == hd*hd*hd + td*td*td + sd*sd*sd)
{
printf("水仙花数字:%d\n",num);
}
}
}
int main() {
int num, sd, td, hd;
for( num =100;num <1000;num++)
{
hd = num/100;
sd = num/10%10;
td = num%10;
if(num == hd*hd*hd + td*td*td + sd*sd*sd)
{
printf("水仙花数字:%d\n",num);
}
}
}
2015-01-22
#include <stdio.h>
int main()
{ int num,sd,td,hd;
for(hd=1;hd<10;hd++)
for(td=0;td<10;td++)
for(sd=0;sd<10;sd++)
{ num=hd*100+td*10+sd;
if(num==hd*hd*hd+td*td*td+sd*sd*sd)
printf("水仙花数字:%d\n",num);
}
return 0;
}
int main()
{ int num,sd,td,hd;
for(hd=1;hd<10;hd++)
for(td=0;td<10;td++)
for(sd=0;sd<10;sd++)
{ num=hd*100+td*10+sd;
if(num==hd*hd*hd+td*td*td+sd*sd*sd)
printf("水仙花数字:%d\n",num);
}
return 0;
}
2015-01-22