C_ÅжÏÓï¾äifÓëelseµÄ×éºÏʹÓÃ
Ô´Âë:
# include <stdio.h>
int main()
{
int x, y;
printf("ÇëÊäÈë×Ô±äÁ¿x£º");
scanf("%d", &x);
if(x < 6)
{
y = x - 12;
printf("x = %d, y = %d\n", x, y);
}
else if(x < 15)
{
y = 3*x - 1;
printf("x = %d, y = %d\n", x, y);
}
else
{
y = 5*x + 9;
printf("x = %d, y = %d\n", x, y);
}
return 0;
}
Ïà¹ØÎĵµ£º
Àý£º#define NELE(a) (sizeof(a) / sizeof(a[0]))
int main() {
char str[] = {'E', 'M', 'C'};
for (int d=-1; d<=(NELE(str)-2);d++)
printf("%c",str[d+1]);
return 0;
}
ÅжÏprintf£¨£©Êä³öµÄÊÇʲô£¬½á¹û¿ÉÄܳöºõÒâÁÏ£¬Ê²Ã´Ò²Ã»ÓÐÊä³ö£¬ÔÒòÄØ£¿ÔÒò ......
#include <stdio.h>
#define MAX 100
int a[MAX], b[MAX], count = 0;
void rData()
{ int i;
FILE *fp;
fp = fopen("C:\\100.dat", "r");
for (i=0; i<MAX; i++)
fscanf(fp, "%d,", &a[i]);
fclose(fp);
}
void main()
{ int i;
rData();
//printf("Âú×ãÌõ¼þµÄÊý= ......
C++¶Ôʱ¼äµÄ²Ù×÷Ò²ÓÐÐí¶àÖµµÃ´ó¼Ò×¢ÒâµÄµØ·½¡£×î½ü£¬ÔÚ¼¼ÊõȺÖÐÓкܶàÍøÓÑÒ²¶à´ÎÎʵ½¹ýC++ÓïÑÔÖжÔʱ¼äµÄ²Ù×÷¡¢»ñÈ¡ºÍÏÔʾµÈµÈµÄÎÊÌâ¡£ÏÂÃ棬ÔÚÕâƪÎÄÕÂÖУ¬±ÊÕß½«Ö÷Òª½éÉÜÔÚC/C++ÖÐʱ¼äºÍÈÕÆÚµÄʹÓ÷½·¨.
ͨ¹ýѧϰÐí¶àC/C++¿â£¬Äã¿ÉÒÔÓкܶà²Ù×÷¡¢Ê¹ÓÃʱ¼äµÄ·½·¨¡£µ«Ô ......
Ô´Âë:
# include <stdio.h>
int main()
{
/* ¶¨Òå±äÁ¿²¢¸³³õÖµ */
int a = 5;
char c = 'a'; // 'a'µÄASCÂëµÄֵΪ97
  ......
Ô´Âë:
# include <stdio.h>
int main()
{
/* ¶¨ÒåÁËÒ»¸öÎÞ·ûºÅ×Ö·ûÐͱäÁ¿£¬´Ë±äÁ¿Ö»ÄÜÓÃÀ´´æ´¢ÎÞ·ûºÅÊý */
unsigned char result;
int a, b, c, d;
a = 2;
b = 4; ......