回顾习题1
来源:互联网 发布:传奇盛世羽毛升级数据 编辑:程序博客网 时间:2024/05/16 17:38
读取键盘输入字符的数目:
test1.c
#include <stdio.h>
int main(){
int num=0;
char c;
while ( (c=getchar()) != '\n'){
num++;
}
printf("Enter number is :%d\n",num);
}
test2.c
#include <stdio.h>
int main()
{
int num=0;
char c;
loop:
if ( (c=getchar() ) != '\n' )
{
num ++;
goto loop;
}
printf("Enter number is :%d\n",num);
}
输出101-200之间的所有素数。注:用这个数分别除 2到这个数加1的平方根 范围内
的每个数。
sushu.c
#include <stdio.h>
#include <math.h>
int main()
{
int num,i;
float sqr;
for (num = 101;num <= 200;num++)
{
sqr=sqrt(num+1);
for (i=2;i<sqr;i++)
{
if ( (num/i)!=0 )
printf("%d ",num);
}
}
}
编译错误,错误代码:
/tmp/ccc4UFlw.o(.text+0x1b): In function `main':
: undefined reference to `sqrt'
collect2: ld returned 1 exit status
Q:以上意思好像是说找不到sqrt函数,问题在哪?
打印九九乘法表:
chengfa1.c
#include <stdio.h>
int main()
{
int j,k;
for (j=1;j<=9;j++)
{
for (k=1;k<=j;k++)
{
printf("%4d",j*k);
}
printf("\n");
}
}
chengfa2.c
#include <stdio.h>
int main()
{
int a[9][9];
int j,k;
for (j=1;j<=9;j++)
{
for (k=1;k<=j;k++)
{
a[j-1][k-1]=j*k;
printf("%4d",a[j-1][k-1]);
}
printf("\n");
}
}
- 回顾习题1
- 重点回顾,课后习题
- 回顾习题2 (11-08-21)
- 回顾习题3 (11-08-22)
- 回顾习题4(11-08-31)
- 回顾习题5(11-09-08)
- 回顾习题6(11-09-30)
- 数据结构习题回顾与总结 (2) List Leaves
- 习题1
- 习题1
- 习题-1
- 习题1
- 习题1
- 习题1
- 习题1
- 习题1
- 习题1
- 习题1
- DBA 需要养成的习惯
- APK反编译
- jstestdrive / asynchronous
- WHY IS GREP
- 机会在眼前溜走了,自己还是要有计划
- 回顾习题1
- xlib编程-一个简单的xlib程序
- jQuery最佳实践
- asp.net中加入收藏及设为首页代码
- 让程序在崩溃时体面的退出之终极解决方案(SEH+Dump+Unhandled Exception Filter)
- HDU 1028
- asp.net中用button关闭当前页面方法
- 爱的力量
- asp.net中嵌入日历控件代码