您的位置:首页 > 其它

#每日一练-1#

2014-04-10 21:52 267 查看
#include <stdio.h>

#if 0 //test 1
void main(void)
{
int input;
char output1;
//char output2;

printf("please input ASCII symbol:");
scanf("%d",&input);
output1=(char)input;
//output2='input';

printf("output1=%c\n",output1);

}

int main(void)
{
int ascii;

printf("Enter an ASCII code: ");
scanf("%d", &ascii);
printf("%d is the ASCII code for %c.\n", ascii, ascii);

return 0;
}
#endif

#if 0 //test2
int main(void)
{
float f_number;
printf("Enter an float number: ");
scanf("%f",&f_number);

printf("The input is %f or %e.\n", f_number,f_number);

}
#endif

#if 0 // test3
int main(void)
{
float water_kt;
float water_weight;
float water_molecule;
printf("Enter water weight: ");
scanf("%f",&water_kt);
water_weight=water_kt*950;
water_molecule=water_weight/3.0e-23;

printf("the number of water molecule is %e\n",water_molecule);

}
#endif
int main(void)
{
float mass_mol = 3.0e-23;   /* mass of water molecule in grams */
float mass_qt = 950;        /* mass of quart of water in grams */
float quarts;
float molecules;

printf("Enter the number of quarts of water: ");
scanf("%f", &quarts);
molecules = quarts * mass_qt / mass_mol;
printf("%f quarts of water contain %e molecules.\n", quarts,
molecules);

return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: