2011年7月28日

摘要: 今天在看数组元素的倒置程序时,发现将原来可以正常实现此功能的while语句改为for循环,其结果便出错了,我知道肯定是我的for循环写错了,但我又不知道错在哪,还请各位帮忙指正,不胜感激!结果正确的while循环:# include <stdio.h> int main(void) { int i; int j; int t; int a[7] = {1, 2, 3, 4, 5, 6, 7}; i = 0; j = 6; while (i < j) { t = a[i]; a[i] = a[j]; a[j] = t; i++; j--; } for(i=0; i<7; 阅读全文
posted @ 2011-07-28 19:51 牛虻1984 阅读(473) 评论(5) 推荐(0)

2011年7月19日

摘要: 从几天前开始听郝斌老师的视频C语言课程,觉得讲得不错,其中一直讲到if...else if ... else...才开始编写给输入的成绩分等级的程序,我认为仅用 if 语句完全可以实现这个任务,程序如下: 1 # include <stdio.h> 2 3 int main(void) 4 { 5 float score; 6 7 printf("请输入你的成绩\n"); 8 scanf("%f", &score); 9 10 if ( score < 0 )11 printf("您也太谦虚了\n");12 阅读全文
posted @ 2011-07-19 23:15 牛虻1984 阅读(333) 评论(3) 推荐(0)

导航