作业一
我编写的程序:
#include<stdio.h>
void main ()
{
printf("我今天吃饭花了:%7.2f\n",18.50);
printf("我学号后两位是:%7.2i\n",28);
printf("我的大名是 : %7s\n","王某");
printf("我的班级是 : %7s\n:" ,"一班");
}
运行的结果:
——————————任务分割线————————————
任务二
我编写的程序:
#include<stdio.h>
void main ()
{
printf("c语言中\\n 代表转义为换行\n");
printf("c语言中\\ 代表转义为一个反斜线字符\n");
printf("c语言中\printf()函数格式为:\ printf<\"<格式化字符串>\",<参量表>>\n");
printf("c语言中\'A'代码字符A,而\"A\"代表字符串\A\n");
}
运行的结果:
——————————————任务分割线———————————————
任务三:
我编写的程序:
#include<stdio.h>
void main ()
{
int a,b;
printf("用“空格”间隔输入学号和手机号后两位:");
scanf("%d%d\n",&a,&b);
printf("学号:%d 手机:%d\n",a,b);
int a,b,c;
printf("用逗号间隔输入整形数字:");
scanf("%d,%d,%d\n",&a,&b,&c);
printf("我输入了3个整形数字:%d,%d,%d\n",a,b,c);
float f1,f2;
printf("用逗号间隔输入浮点数:");
scanf("%f,%f\n",&f1,&f2);
printf("输入的浮点数分别是:%F,%g\n",f1,f2);
}
运行的结果出现错误:
1> 3.cpp
1>c:\users\administrator\documents\visual studio 2012\projects\3\3\3.cpp(6): warning C4996: 'scanf': This function or variable may be unsafe. Consider using scanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> c:\program files\microsoft visual studio 11.0\vc\include\stdio.h(290) : 参见“scanf”的声明
1>c:\users\administrator\documents\visual studio 2012\projects\3\3\3.cpp(10): error C2086: “int a”: 重定义
1> c:\users\administrator\documents\visual studio 2012\projects\3\3\3.cpp(4) : 参见“a”的声明
1>c:\users\administrator\documents\visual studio 2012\projects\3\3\3.cpp(10): error C2086: “int b”: 重定义
1> c:\users\administrator\documents\visual studio 2012\projects\3\3\3.cpp(4) : 参见“b”的声明
========== 全部重新生成: 成功 0 个,失败 1 个,跳过 0 个 ==========
自己看了半天,抱着试一试的态度去改了程序
改写后的程序:
#include<stdio.h>
void main ()
{
int a,b,c;
printf("用“空格”间隔输入学号和手机号后两位:");
scanf("%d%d",&a,&b);
printf("学号: %d 手机:%d\n",a,b);
printf("\n");
printf("用“逗号”间隔输入整形数字:");
scanf("%d,%d,%d",&a,&b,&c);
printf("我输入了3个整形数字:%d,%d,%d\n",a,b,c);
printf("\n");
float f1,f2;
printf("用“逗号”间隔输入浮点数:");
scanf("%f,%f",&f1,&f2);
printf("输入的浮点数分别是:%f,%f\n",f1,f2);
}
程序运行的结果:
——————————任务分割线———————————
任务四:
读《不要再拿兴趣说事》有感
从来都不觉得那些成绩不好的人就一定是智商不行,但是一直觉得成绩不好的人90%是懒惰,甚至是一种害怕面对现实的懦弱!!特别是在大学挂科的人,绝对不是智商不行,智商不行的话又怎么考上了大学,在他们的眼中,大学就是一个可以无限放纵自己的一段时光!!但是,我倒觉得,我们初中不好好学只是影响自己能否进入好的高中,高中不好,只是影响大学,可是,大学不好好争气的话,很有可能影响的使我们的一辈子!!不要为自己的懒惰找借口,懒惰的人就算是在自己感兴趣的专业一样挂科!!